From portal-commits at lists.jboss.org Tue Apr 7 10:27:15 2009 Content-Type: multipart/mixed; boundary="===============2692528093545785471==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r13172 - in branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests: src/org/jboss/portal/test/selenium and 1 other directory. Date: Tue, 07 Apr 2009 10:27:15 -0400 Message-ID: --===============2692528093545785471== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: vrockai Date: 2009-04-07 10:27:15 -0400 (Tue, 07 Apr 2009) New Revision: 13172 Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/build.xml branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal= /test/selenium/JBossPortalSeleniumTestCase.java Log: [selenium] - javadoc dir not deleted when running tests Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/build.xml 2009-04-0= 7 13:55:24 UTC (rev 13171) +++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/build.xml 2009-04-0= 7 14:27:15 UTC (rev 13172) @@ -68,7 +68,7 @@ - + = = @@ -80,6 +80,7 @@ = + Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss= /portal/test/selenium/JBossPortalSeleniumTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/porta= l/test/selenium/JBossPortalSeleniumTestCase.java 2009-04-07 13:55:24 UTC (r= ev 13171) +++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/porta= l/test/selenium/JBossPortalSeleniumTestCase.java 2009-04-07 14:27:15 UTC (r= ev 13172) @@ -12,6 +12,12 @@ import com.thoughtworks.selenium.Selenium; = /** + * JBossPortalSeleniumTestCase is the main class used in JBoss Portal sele= nium + * testing. Each testcase class has to extend this class. The + * JBossPortalSeleniumTestCase contains many basic methods for simple + * orientation in JBoss Portal like login/logout or finding elements in ta= ble. + * It also encapsulates selenium javascript extensions used in the tests. + * = * @author Viliam Rockai */ public class JBossPortalSeleniumTestCase { @@ -27,26 +33,30 @@ } } = - public final String LINK_LOGOUT =3D getProp(casePfx + "link.logout", "lin= k=3DLogout"); - public final String SUBMIT_LOGIN =3D getProp(casePfx + "submit.login", "l= ogin"); - public final String ADDR_PORTAL =3D getProp(casePfx + "addr.portal", "/po= rtal/"); - public final String FRAME_LOGIN_CONTENT =3D getProp(casePfx + "frame.logi= n.content", "login-content"); - public final String LINK_LOGIN =3D getProp(casePfx + "link.login", "link= =3DLogin"); - public final String INPUT_PASSWORD =3D getProp(casePfx + "input.password"= , "j_password"); - public final String INPUT_USERNAME =3D getProp(casePfx + "input.username"= , "j_username"); + protected final String LINK_LOGOUT =3D getProp(casePfx + "link.logout", "= link=3DLogout"); + protected final String SUBMIT_LOGIN =3D getProp(casePfx + "submit.login",= "login"); + protected final String ADDR_PORTAL =3D getProp(casePfx + "addr.portal", "= /portal/"); + protected final String FRAME_LOGIN_CONTENT =3D getProp(casePfx + "frame.l= ogin.content", "login-content"); + protected final String LINK_LOGIN =3D getProp(casePfx + "link.login", "li= nk=3DLogin"); + protected final String INPUT_PASSWORD =3D getProp(casePfx + "input.passwo= rd", "j_password"); + protected final String INPUT_USERNAME =3D getProp(casePfx + "input.userna= me", "j_username"); = protected static Properties props; protected Selenium selenium; = - // Generic timeout in miliseconds - protected static final String PAGE_LOAD =3D "2400000"; - protected static final long AJAX_LOAD =3D 3000; + /** + * Generic timeout in miliseconds used in every selenium function + * waitForPageToLoad()} + */ + public static final String PAGE_LOAD =3D "2400000"; + /** Generic timeout in miliseconds used for AJAX timeouts } */ + public static final long AJAX_LOAD =3D 3000; = // protected static final String PAGE_LOAD =3D "60000"; // protected static final long AJAX_LOAD =3D 2000; = - // Element timeout in seconds - protected static final int ELEM_TIMEOUT =3D 220; + /** Element timeout in seconds used in waitForElement functions */ + public static final int ELEM_TIMEOUT =3D 220; = @BeforeClass protected void setupChromeForLogin() throws Exception { @@ -82,6 +92,18 @@ return props; } = + /** + * Gets the property. Property file is named locator.properties and it's + * located in the org.jboss.portal.test.selenium package. It contains + * locator properties for all locators used in selenium tests. + * = + * @param prop + * the name of the property + * @param subst + * the value which is returned in the case the property isn't = set + * = + * @return the prop + */ public String getProp(String prop, String subst) { = if (subst =3D=3D null || "".equals(subst)) { @@ -97,6 +119,12 @@ } } = + /** + * Click on an element only in case element is present on the screen. + * = + * @param id + * the id + */ public void clickIfVisible(String id) { = if (selenium.isElementPresent(id)) { @@ -106,15 +134,47 @@ } } = + /** + * Finding the correct row in a table due to input string and columns. The + * function uses selenium javascript extension findTableRow. It tries to + * look up the input string in the chosen column in selected table. After + * the first occurrence of input string, it returns the number of row whe= re + * it was found. + * = + * @param tableLocation + * the table locator + * @param searchName + * the string which the function searches for + * @param searchCol + * the column in which the function searches for + * = + * @return the number of row with the first occurrence of searchName stri= ng. + */ public int findTableRow(String tableLocation, String searchName, int sear= chCol) { return Integer.valueOf(selenium.getEval("selenium.findTableRow(\"" + tab= leLocation + "\",'" + searchName + "'," + searchCol + ")")); } = + /** + * Counts table rows for selected table. + * = + * @param tableLocation + * the table locator + * = + * @return the number of rows of the table + */ public int countTableRows(String tableLocation) { return Integer.valueOf(selenium.getEval("selenium.countTableRows(\"" + t= ableLocation + "\")")); } = // TODO refactor + /** + * Safe select. + * = + * @param locator + * the locator + * @param value + * the value + */ public void safeSelect(String locator, String value) { waitForElement(locator); = @@ -143,17 +203,33 @@ selenium.select(locator, "label=3D" + value); } = + /** + * Click and wait. + * = + * @param locator the locator + */ public void clickAndWait(String locator) { waitForElement(locator); selenium.click(locator); selenium.waitForPageToLoad(PAGE_LOAD); } = + /** + * Open and wait. + * = + * @param locator the locator + */ public void openAndWait(String locator) { selenium.open(locator); selenium.waitForPageToLoad(PAGE_LOAD); } - = + + /** + * Select if not selected. + * = + * @param selector the selector + * @param label the label + */ public void selectIfNotSelected(String selector, String label) { waitForElement(selector); if (!selenium.getSelectedLabel(selector).equals(label)) { @@ -162,6 +238,13 @@ } } = + /** + * Assert text order. + * = + * @param text the text + * = + * @return true, if successful + */ public boolean assertTextOrder(String text) { return Boolean.valueOf(selenium.getEval("selenium.assertTextOrder(\"" + = text + "\")")); } @@ -169,7 +252,8 @@ /** * Waits for specified time in ms. Used mostly in AJAX based tests. * = - * @param time the time (in ms) to be waited for. + * @param time + * the time (in ms) to be waited for. */ public void waitFor(long time) { try { @@ -181,9 +265,11 @@ } = /** - * Waits for element to appear on the screen. Used mostly in AJAX based t= ests. + * Waits for element to appear on the screen. Used mostly in AJAX based + * tests. * = - * @param locator the locator of the element to be waited for + * @param locator + * the locator of the element to be waited for */ public void waitForElement(String locator) { for (int second =3D 0;; second++) { @@ -201,14 +287,19 @@ } = /** - * Waits for element to appear on the screen. Used mostly in AJAX based t= ests. + * Waits for element to appear on the screen. Used mostly in AJAX based + * tests. * = - * @param locatorElem the element locator - * @param locatorLink the link locator - not used - * @param timeToWait the time (in ms) to wait until timeout is reached - * @param n the n + * @param locatorElem + * the element locator + * @param locatorLink + * the link locator - not used + * @param timeToWait + * the time (in ms) to wait until timeout is reached + * @param n + * the n */ - //TODO refactor - locatorLink is not used + // TODO refactor - locatorLink is not used public void waitForElement(String locatorElem, String locatorLink, long t= imeToWait, long n) { for (int i =3D 0;; i++) { if (i >=3D n) { @@ -227,7 +318,8 @@ /** * Waits for text to appear on the screen. Used mostly in AJAX based test= s. * = - * @param text the text to be waited for + * @param text + * the text to be waited for */ public void waitForText(String text) { for (int second =3D 0;; second++) { @@ -247,8 +339,10 @@ /** * Login into JBoss portal. * = - * @param username the username - * @param password the password + * @param username + * the username + * @param password + * the password */ public void login(String username, String password) { selenium.open(ADDR_PORTAL); @@ -285,7 +379,7 @@ /** * Logs out from portal application if a user is logged in. */ - //TODO refactoring needed - use function logout() + // TODO refactoring needed - use function logout() public void logoutIfPossible() { selenium.open(ADDR_PORTAL); selenium.waitForPageToLoad(PAGE_LOAD); @@ -298,9 +392,12 @@ } = /** - * Prints a message into the system output for debugging purposes. The me= ssage is printed only in the case, if the value true of parameter debug<= /i> was passed to jvm with -Ddebug=3D"true" switch. = + * Prints a message into the system output for debugging purposes. The + * message is printed only in the case, if the value true of parameter + * debug was passed to jvm with -Ddebug=3D"true" switch. * = - * @param debugText the debug text + * @param debugText + * the debug text */ public void debugPrint(String debugText) { if (JBossSeleniumTestListener.debug) @@ -308,9 +405,12 @@ } = /** - * Captures screenshot for debugging purposes. Saves a screenshot into de= bug directory. The screenshot is saved only in the case, if the value true = of parameter debug was passed to jvm with -Ddebug=3D"true" switch. + * Captures screenshot for debugging purposes. Saves a screenshot into de= bug + * directory. The screenshot is saved only in the case, if the value true= of + * parameter debug was passed to jvm with -Ddebug=3D"true" switch. * = - * @param filename the filename of the debug screenshot + * @param filename + * the filename of the debug screenshot */ public void debugScreenshot(String filename) { if (JBossSeleniumTestListener.debug) --===============2692528093545785471==--