Author: vrockai
Date: 2009-02-04 05:06:14 -0500 (Wed, 04 Feb 2009)
New Revision: 12770
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
Log:
selenium import fixes, userlogin more tests
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-02-03
17:46:31 UTC (rev 12769)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-02-04
10:06:14 UTC (rev 12770)
@@ -17,7 +17,7 @@
private static final String LINK_WEATHER_PORTLET = "link=*WeatherPortlet*";
private static final String LINK_PORTL2 = "link=*Who's online portlet*";
private static final String LINK_PORTL1 = "link=*Welcome portlet*";
- private static final String OPT_PORTL2 = "CurrentUsersPortletWindow";
+ //private static final String OPT_PORTL2 = "CurrentUsersPortletWindow";
private static final String OPT_PORTL1 = "JSPPortletWindow";
private static final String SEL_CONTENT_TYPE =
"//select[contains(@id,'contentTypesForm:instanceId')]";
private static final String SUB_DEL_FROM_CENTER_REGION =
"//input[contains(@id,'layoutForm:l_center')]";
@@ -32,7 +32,7 @@
private static final String INP_PAGENAME =
"//input[contains(@id,':pageName')]";
private static final String SUB_CREATEPAGE =
"//form[contains(@id,'j_id3')]/input[@type='submit']";
private static final String SEL_LAYOUT =
"//select[contains(@id,'dashboardLayoutForm:layoutSelector')]";
- private static final String SUB_LAYOUTSEL =
"//form[contains(@id,'dashboardLayoutForm')]/input[@type='submit']";
+
private static final String SEL_THEME =
"//select[contains(@id,'dashboardThemeForm:themeSelector')]";
private static final String SUB_THEMESEL =
"//form[contains(@id,'dashboardThemeForm')]/input[@type='submit']";
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-02-03
17:46:31 UTC (rev 12769)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-02-04
10:06:14 UTC (rev 12770)
@@ -1,16 +1,10 @@
package org.jboss.portal.test.selenium;
-import java.awt.event.InputMethodEvent;
-import java.awt.event.InputMethodListener;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.List;
-import org.testng.IMethodInstance;
-import org.testng.IMethodInterceptor;
-import org.testng.ITestContext;
import org.testng.ITestResult;
import org.testng.TestListenerAdapter;
@@ -40,7 +34,7 @@
public void onTestFailure(ITestResult tr) {
String name = "F_" + tr.getName() + "-" + count;
-
+
if (htmlSource) {
try {
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(name +
".html")));
@@ -50,7 +44,7 @@
e1.printStackTrace();
}
}
- if (screenshot){
+ if (screenshot) {
try {
selenium.windowMaximize();
selenium.captureScreenshot(name + ".jpg");
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java 2009-02-03
17:46:31 UTC (rev 12769)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java 2009-02-04
10:06:14 UTC (rev 12770)
@@ -1,8 +1,6 @@
package org.jboss.portal.test.selenium;
-import java.text.DateFormat;
import java.text.ParseException;
-import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
@@ -14,6 +12,9 @@
@Test(groups = { "cms_user_interceptor" }, enabled = true, description =
"Checking the log of logging of users.")
public class UserInterceptorPortletTestCase extends JBossPortalSeleniumTestCase {
+ private static final String LNK_USER_DETAILS = "link=UsersDetailPage";
+ private static final String DIV_LOGINFO =
"//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div";
+
@Test(enabled = true, description = "Checking the logging dates for user.")
public void testTestUserLogger() throws ParseException {
@@ -26,7 +27,6 @@
}
private int dateDiff(String name, String passwd, int ind) throws ParseException {
- DateFormat df = new SimpleDateFormat("E MMM dd HH:mm:ss z yyyy");
Vector<String> vs;
String logInfo;
@@ -34,25 +34,25 @@
logout();
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=UsersDetailPage");
+ selenium.click(LNK_USER_DETAILS);
selenium.waitForPageToLoad(PAGE_LOAD);
- logInfo =
selenium.getText("//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div");
+ logInfo = selenium.getText(DIV_LOGINFO);
vs = parseUserInterceptorString(logInfo);
- Date d1 = new Date(Long.valueOf(vs.get(ind)));//df.parse(vs.get(ind));
+ Date d1 = new Date(Long.valueOf(vs.get(ind)));
login(name, passwd);
logout();
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=UsersDetailPage");
+ selenium.click(LNK_USER_DETAILS);
selenium.waitForPageToLoad(PAGE_LOAD);
- logInfo =
selenium.getText("//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div");
+ logInfo = selenium.getText(DIV_LOGINFO);
vs = parseUserInterceptorString(logInfo);
- Date d2 = new Date(Long.valueOf(vs.get(ind)));//df.parse(vs.get(ind));
+ Date d2 = new Date(Long.valueOf(vs.get(ind)));
return d2.compareTo(d1);
}
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-02-03
17:46:31 UTC (rev 12769)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-02-04
10:06:14 UTC (rev 12770)
@@ -11,111 +11,170 @@
@Test(groups = { "login" }, enabled = true)
public class UserLoginTestCase extends JBossPortalSeleniumTestCase {
+ private static final String ADR_PORTAL = "/portal";
+ private static final String FRM_MAIN = "relative=up";
+ private static final String SUB_CANCEL = "cancel";
+ private static final String LNK_LOGOUT = "link=Logout";
+ private static final String SUB_LOGIN = "login";
+ private static final String INP_PASSWORD = "xpath=id('j_password')";
+ private static final String INP_USERNAME = "xpath=id('j_username')";
+ private static final String FRM_LOGINFORM = "login-content";
+ private static final String LNK_LOGIN = "link=Login";
+
@AfterClass(enabled = true)
public void logoutIfNeeded()
{
- selenium.open("/portal");
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- if (selenium.isElementPresent("link=Logout")){
- selenium.click("link=Logout");
+ if (selenium.isElementPresent(LNK_LOGOUT)){
+ selenium.click(LNK_LOGOUT);
selenium.waitForPageToLoad(PAGE_LOAD);
}
}
@Test(enabled = true, description = "login as default user 'user' with
password 'user'.")
public void testDefaultUserLogin() throws Exception {
- //selenium.setSpeed("7000");
- selenium.open("/portal");
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("link=Login"), "Expected DOM
element for login link does not exist.");
- Assert.assertEquals(selenium.getText("link=Login"), "Login",
"Login button doesn't exist.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Expected DOM element for
login link does not exist.");
+ Assert.assertEquals(selenium.getText(LNK_LOGIN), "Login", "Login button
doesn't exist.");
- selenium.click("link=Login");
- selenium.selectFrame("login-content");
+ selenium.click(LNK_LOGIN);
+ selenium.selectFrame(FRM_LOGINFORM);
- waitForElement("xpath=id('j_username')");
- waitForElement("xpath=id('j_password')");
+ waitForElement(INP_USERNAME);
+ waitForElement(INP_PASSWORD);
- Assert.assertTrue(selenium.isElementPresent("xpath=id('j_username')"),
"Expected input DOM element for username doesn't exist.");
- selenium.type("j_username", "user");
- Assert.assertTrue(selenium.isElementPresent("xpath=id('j_password')"),
"Expected input DOM element for password doesn't exist.");
- selenium.type("j_password", "user");
- selenium.click("login");
+ Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM
element for username doesn't exist.");
+ selenium.type(INP_USERNAME, "user");
+ Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM
element for password doesn't exist.");
+ selenium.type(INP_PASSWORD, "user");
+ selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Logged in as: user"),
"\"Logged in as\" message missing.");
- Assert.assertTrue(selenium.isElementPresent("link=Logout"), "Expected
DOM element for login link does not exist.");
- Assert.assertEquals(selenium.getText("link=Logout"), "Logout",
"Logout has wrong label.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGOUT), "Expected DOM element for
login link does not exist.");
+ Assert.assertEquals(selenium.getText(LNK_LOGOUT), "Logout", "Logout has
wrong label.");
- selenium.click("link=Logout");
+ selenium.click(LNK_LOGOUT);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent("Logged in as:"),
"\"Logged in as:\" message with no user logged in is missing.");
}
@Test(enabled = true, description = "login as admin user 'admin' with
password 'admin'.")
public void testAdminLogin() throws Exception {
- selenium.open("/portal");
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- waitForElement("link=Login");
- Assert.assertTrue(selenium.isElementPresent("link=Login"), "Expected DOM
element for login link does not exist.");
- Assert.assertEquals(selenium.getText("link=Login"), "Login",
"Login button doesn't exist.");
+ waitForElement(LNK_LOGIN);
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Expected DOM element for
login link does not exist.");
+ Assert.assertEquals(selenium.getText(LNK_LOGIN), "Login", "Login button
doesn't exist.");
- selenium.click("link=Login");
- selenium.selectFrame("login-content");
+ selenium.click(LNK_LOGIN);
+ selenium.selectFrame(FRM_LOGINFORM);
- waitForElement("xpath=id('j_username')");
- waitForElement("xpath=id('j_password')");
+ waitForElement(INP_USERNAME);
+ waitForElement(INP_PASSWORD);
- Assert.assertTrue(selenium.isElementPresent("xpath=id('j_username')"),
"Expected input DOM element for username doesn't exist.");
- selenium.type("j_username", "admin");
- Assert.assertTrue(selenium.isElementPresent("xpath=id('j_password')"),
"Expected input DOM element for password doesn't exist.");
- selenium.type("j_password", "admin");
- selenium.click("login");
+ Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM
element for username doesn't exist.");
+ selenium.type(INP_USERNAME, "admin");
+ Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM
element for password doesn't exist.");
+ selenium.type(INP_PASSWORD, "admin");
+ selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Logged in as: admin"),
"\"Logged in as\" message missing.");
- Assert.assertTrue(selenium.isElementPresent("link=Logout"), "Expected
DOM element for login link does not exist.");
- Assert.assertEquals(selenium.getText("link=Logout"), "Logout",
"Logout has wrong label.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGOUT), "Expected DOM element for
login link does not exist.");
+ Assert.assertEquals(selenium.getText(LNK_LOGOUT), "Logout", "Logout has
wrong label.");
- selenium.click("link=Logout");
+ selenium.click(LNK_LOGOUT);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent("Logged in as:"),
"\"Logged in as:\" message with no user logged in is missing.");
}
@Test(enabled = true, description = "canceling of the login form.")
public void testUserLoginCancel() throws Exception {
- selenium.open("/portal");
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent("Logged in as:"),
"\"Logged in as:\" message with no user logged in is missing.");
- Assert.assertTrue(selenium.isElementPresent("link=Login"), "DOM element
for login link not found.");
- Assert.assertEquals(selenium.getText("link=Login"), "Login",
"Login button doesn't exist.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "DOM element for login
link not found.");
+ Assert.assertEquals(selenium.getText(LNK_LOGIN), "Login", "Login button
doesn't exist.");
- selenium.click("link=Login");
- selenium.selectFrame("login-content");
+ selenium.click(LNK_LOGIN);
+ selenium.selectFrame(FRM_LOGINFORM);
- waitForElement("xpath=id('j_username')");
- waitForElement("xpath=id('j_password')");
+ waitForElement(INP_USERNAME);
+ waitForElement(INP_PASSWORD);
- Assert.assertTrue(selenium.isElementPresent("xpath=id('j_username')"),
"Expected input DOM element for username doesn't exist.");
- selenium.type("j_username", "saki");
- Assert.assertTrue(selenium.isElementPresent("xpath=id('j_password')"),
"Expected input DOM element for password doesn't exist.");
- selenium.type("j_password", "paki");
+ Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM
element for username doesn't exist.");
+ selenium.type(INP_USERNAME, "saki");
+ Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM
element for password doesn't exist.");
+ selenium.type(INP_PASSWORD, "paki");
- selenium.click("cancel");
- selenium.selectFrame("relative=up");
+ selenium.click(SUB_CANCEL);
+ selenium.selectFrame(FRM_MAIN);
- Assert.assertTrue(selenium.isElementPresent("link=Login"), "DOM element
for login link not found.");
- Assert.assertEquals(selenium.getText("link=Login"), "Login",
"Login button doesn't exist.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "DOM element for login
link not found.");
+ Assert.assertEquals(selenium.getText(LNK_LOGIN), "Login", "Login button
doesn't exist.");
Assert.assertFalse(selenium.isTextPresent("Logged in as:"),
"\"Logged in as:\" message with no user logged in is missing.");
}
+
+ @Test(enabled = true, description = "login as 'us2er' which does not
exist.")
+ public void testFalseNameLogin() throws Exception {
+ selenium.open(ADR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Expected DOM element for
login link does not exist.");
+ Assert.assertEquals(selenium.getText(LNK_LOGIN), "Login", "Login button
doesn't exist.");
+
+ selenium.click(LNK_LOGIN);
+ selenium.selectFrame(FRM_LOGINFORM);
+
+ waitForElement(INP_USERNAME);
+ waitForElement(INP_PASSWORD);
+
+ Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM
element for username doesn't exist.");
+ selenium.type(INP_USERNAME, "us2er");
+ Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM
element for password doesn't exist.");
+ selenium.type(INP_PASSWORD, "user");
+ selenium.click(SUB_LOGIN);
+
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent("The user doesn't exist or the
password is incorrect "), "\"Logged in as\" message missing.");
+ }
+
+ @Test(enabled = true, description = "login as 'user' with wrong password
'us2er'.")
+ public void testFalsePasswordLogin() throws Exception {
+ selenium.open(ADR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Expected DOM element for
login link does not exist.");
+ Assert.assertEquals(selenium.getText(LNK_LOGIN), "Login", "Login button
doesn't exist.");
+
+ selenium.click(LNK_LOGIN);
+ selenium.selectFrame(FRM_LOGINFORM);
+
+ waitForElement(INP_USERNAME);
+ waitForElement(INP_PASSWORD);
+
+ Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM
element for username doesn't exist.");
+ selenium.type(INP_USERNAME, "user");
+ Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM
element for password doesn't exist.");
+ selenium.type(INP_PASSWORD, "us2er");
+ selenium.click(SUB_LOGIN);
+
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent("The user doesn't exist or the
password is incorrect "), "\"Logged in as\" message missing.");
+ }
+
}
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-02-03
17:46:31 UTC (rev 12769)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-02-04
10:06:14 UTC (rev 12770)
@@ -42,9 +42,6 @@
private static final String
LINK_T_CONS_DER="//a[contains(@id,''consumer-list-form:consumersList:{0}:register'')]";
private static final String
LINK_T_CONS_DEL="//a[contains(@id,''consumer-list-form:consumersList:{0}:delete'')]";
-
-
-
public static String WSRP_CONSUMER_TABLE =
"//table[contains(@id,':consumer-list-form:consumersList')]";
@BeforeMethod(groups = { "log" })
public void loginBeforeTest() {
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-02-03
17:46:31 UTC (rev 12769)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-02-04
10:06:14 UTC (rev 12770)
@@ -18,8 +18,6 @@
private static final String LNK_EXPLORE =
"//area[(a)href='/portal/content/default/epp.html']";
private static final String LNK_CMS_EXPLORE = "Link=epp.html";
- private static final String LNK_SUPPORT_HTML =
"//area[(a)href='/portal/content/default/project.html']";
- private static final String LNK_CMS_SUPPORT_HTML = "Link=project.html";
private static final String LNK_MEMBERS = "link=Members";
private static final String SUB_SECURITY_SET =
"//input[contains(@name,'submit')]";
private static final String SEL_SECUREUSERS_MANAGE =
"//select[contains(@name,'secureusers:manage')]";
@@ -165,10 +163,6 @@
login("admin", "admin");
Assert.assertFalse(selenium.isTextPresent("Access to this resource is denied
"), "Non secured resource is not visible.#1");
- // Assert.assertFalse(selenium.isTextPresent(
- // "You are not allowed to access the following resource -
/default/index.html"
- // ),
- // "Non secured resource is not visible.#2");
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -401,7 +395,6 @@
selenium.type(IdentityAdminTestCase.ID_INPUT_SEARCH_USER, username);
selenium.click(IdentityAdminTestCase.ID_SUBMIT_SEARCH_USER);
- // selenium.waitForPageToLoad(PAGE_LOAD);
try {
Thread.sleep(5000);
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-02-03
17:46:31 UTC (rev 12769)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-02-04
10:06:14 UTC (rev 12770)
@@ -270,7 +270,7 @@
// click on the page layout
selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
- //selenium.waitForPageToLoad(PAGE_LOAD);
+
try {
Thread.sleep(5000);
} catch (InterruptedException e) {