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
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/build.xml 2009-04-07 13:55:24 UTC
(rev 13171)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/build.xml 2009-04-07 14:27:15 UTC
(rev 13172)
@@ -68,7 +68,7 @@
<echo message="Deleting testng report directory" />
<delete dir="${testng.output.dir}" />
<delete dir="${testng.debug.dir}" />
- <delete dir="${dir.javadoc}" />
+ <!--delete dir="${dir.javadoc}" /-->
</target>
@@ -80,6 +80,7 @@
</target>
<target name="javadoc" depends="">
+ <delete dir="${dir.javadoc}" />
<mkdir dir="${dir.javadoc}" />
<javadoc packagenames="org.jboss.portal.test.selenium.*"
classpathref="libraries.cp" access="public"
destdir="${dir.javadoc}" author="true" version="true"
use="true">
<fileset dir="${test.src.dir}" defaultexcludes="yes">
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-04-07
13:55:24 UTC (rev 13171)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-04-07
14:27:15 UTC (rev 13172)
@@ -12,6 +12,12 @@
import com.thoughtworks.selenium.Selenium;
/**
+ * JBossPortalSeleniumTestCase is the main class used in JBoss Portal selenium
+ * 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 table.
+ * It also encapsulates selenium javascript extensions used in the tests.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
public class JBossPortalSeleniumTestCase {
@@ -27,26 +33,30 @@
}
}
- public final String LINK_LOGOUT = getProp(casePfx + "link.logout",
"link=Logout");
- public final String SUBMIT_LOGIN = getProp(casePfx + "submit.login",
"login");
- public final String ADDR_PORTAL = getProp(casePfx + "addr.portal",
"/portal/");
- public final String FRAME_LOGIN_CONTENT = getProp(casePfx +
"frame.login.content", "login-content");
- public final String LINK_LOGIN = getProp(casePfx + "link.login",
"link=Login");
- public final String INPUT_PASSWORD = getProp(casePfx + "input.password",
"j_password");
- public final String INPUT_USERNAME = getProp(casePfx + "input.username",
"j_username");
+ protected final String LINK_LOGOUT = getProp(casePfx + "link.logout",
"link=Logout");
+ protected final String SUBMIT_LOGIN = getProp(casePfx + "submit.login",
"login");
+ protected final String ADDR_PORTAL = getProp(casePfx + "addr.portal",
"/portal/");
+ protected final String FRAME_LOGIN_CONTENT = getProp(casePfx +
"frame.login.content", "login-content");
+ protected final String LINK_LOGIN = getProp(casePfx + "link.login",
"link=Login");
+ protected final String INPUT_PASSWORD = getProp(casePfx + "input.password",
"j_password");
+ protected final String INPUT_USERNAME = getProp(casePfx + "input.username",
"j_username");
protected static Properties props;
protected Selenium selenium;
- // Generic timeout in miliseconds
- protected static final String PAGE_LOAD = "2400000";
- protected static final long AJAX_LOAD = 3000;
+ /**
+ * Generic timeout in miliseconds used in every selenium function
+ * waitForPageToLoad()}
+ */
+ public static final String PAGE_LOAD = "2400000";
+ /** Generic timeout in miliseconds used for AJAX timeouts } */
+ public static final long AJAX_LOAD = 3000;
// protected static final String PAGE_LOAD = "60000";
// protected static final long AJAX_LOAD = 2000;
- // Element timeout in seconds
- protected static final int ELEM_TIMEOUT = 220;
+ /** Element timeout in seconds used in waitForElement functions */
+ public static final int ELEM_TIMEOUT = 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 == 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 where
+ * 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 string.
+ */
public int findTableRow(String tableLocation, String searchName, int searchCol) {
return Integer.valueOf(selenium.getEval("selenium.findTableRow(\"" +
tableLocation + "\",'" + 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(\"" +
tableLocation + "\")"));
}
// 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=" + 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 tests.
+ * 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 = 0;; second++) {
@@ -201,14 +287,19 @@
}
/**
- * Waits for element to appear on the screen. Used mostly in AJAX based tests.
+ * 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 timeToWait, long
n) {
for (int i = 0;; i++) {
if (i >= n) {
@@ -227,7 +318,8 @@
/**
* Waits for text to appear on the screen. Used mostly in AJAX based tests.
*
- * @param text the text to be waited for
+ * @param text
+ * the text to be waited for
*/
public void waitForText(String text) {
for (int second = 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 message is
printed only in the case, if the value true of parameter <i>debug</i> was
passed to jvm with -Ddebug="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
+ * <i>debug</i> was passed to jvm with -Ddebug="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 debug directory.
The screenshot is saved only in the case, if the value true of parameter
<i>debug</i> was passed to jvm with -Ddebug="true" switch.
+ * Captures screenshot for debugging purposes. Saves a screenshot into debug
+ * directory. The screenshot is saved only in the case, if the value true of
+ * parameter <i>debug</i> was passed to jvm with -Ddebug="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)