Author: vrockai
Date: 2008-10-20 11:35:39 -0400 (Mon, 20 Oct 2008)
New Revision: 12101
Modified:
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/testng.xml
Log:
user login test , waitForElement added
Modified:
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2008-10-20
15:24:57 UTC (rev 12100)
+++
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2008-10-20
15:35:39 UTC (rev 12101)
@@ -18,7 +18,12 @@
public static final String INPUT_PASSWORD = "j_password";
public static final String INPUT_USERNAME = "j_username";
protected Selenium selenium;
+
+ //Generic timeout in miliseconds
protected static final String PAGE_LOAD = "450000";
+
+ //Element timeout in seconds
+ protected static final int ELEM_TIMEOUT = 30;
@BeforeClass
public void setupChromeForLogin() throws Exception {
@@ -97,6 +102,29 @@
return Boolean.valueOf(selenium.getEval("selenium.assertTextOrder(\"" +
text + "\")"));
}
+ protected void waitFor(long time){
+ try {
+ Thread.sleep(time);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void waitForElement(String locator) {
+ for (int second = 0; ; second++) {
+ if (second >= ELEM_TIMEOUT) {
+ Assert.fail("Element "+locator+" not found.");
+ }
+ try {
+ if (selenium.isElementPresent(locator)) break;
+ } catch (Exception e) {
+ }
+ waitFor(1000);
+ }
+ }
+
+
protected void login(String username, String password) {
selenium.open(ADDR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -104,12 +132,10 @@
selenium.click(LINK_LOGIN);
selenium.selectFrame(FRAME_LOGIN_CONTENT);
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+
+ waitForElement(INPUT_USERNAME);
+ waitForElement(INPUT_PASSWORD);
+ waitForElement(SUBMIT_LOGIN);
selenium.type(INPUT_USERNAME, username);
selenium.type(INPUT_PASSWORD, password);
Modified:
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2008-10-20
15:24:57 UTC (rev 12100)
+++
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2008-10-20
15:35:39 UTC (rev 12101)
@@ -35,6 +35,9 @@
selenium.click("link=Login");
selenium.selectFrame("login-content");
+ waitForElement("j_username");
+ waitForElement("j_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.");
@@ -79,6 +82,8 @@
selenium.click("link=Login");
selenium.selectFrame("login-content");
+ waitForElement("j_username");
+ waitForElement("j_password");
Assert.assertTrue(selenium.isElementPresent("xpath=id('j_username')"),
"Expected input DOM element for username doesn't exist.");
selenium.type("j_username", "admin");
@@ -128,6 +133,8 @@
selenium.click("link=Login");
selenium.selectFrame("login-content");
+ waitForElement("j_username");
+ waitForElement("j_password");
Assert.assertTrue(selenium.isElementPresent("xpath=id('j_username')"),
"Expected input DOM element for username doesn't exist.");
selenium.type("j_username", "saki");
Modified: branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/testng.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/testng.xml 2008-10-20 15:24:57 UTC
(rev 12100)
+++ branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/testng.xml 2008-10-20 15:35:39 UTC
(rev 12101)
@@ -16,8 +16,6 @@
<class
name="org.jboss.portal.test.selenium.IdentityAdminTestCase"></class></classes>
</test>
-
-
<test name="org.jboss.portal.test.selenium.PortletUserCreationTestCase"
verbose="2" annotations="JDK">
<classes>
Show replies by date