Author: ppitonak(a)redhat.com
Date: 2009-11-04 06:00:56 -0500 (Wed, 04 Nov 2009)
New Revision: 15823
Modified:
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java
Log:
* added method waitForElement(String, int)
* method waitForElement(String) refactored
Modified:
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java
===================================================================
---
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java 2009-11-04
10:27:01 UTC (rev 15822)
+++
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java 2009-11-04
11:00:56 UTC (rev 15823)
@@ -495,18 +495,23 @@
* the locator of the element to be waited for
*/
public void waitForElement(String locator) {
- for (int second = 0;; second++) {
- if (second >= ELEM_TIMEOUT) {
- Assert.fail("Element " + locator + " not found.");
+ waitForElement(locator, 1000);
+ }
+
+ /**
+ * 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 step interval between two pollings
+ */
+ public void waitForElement(final String locator, int step) {
+ Wait.failWith("Element \"" + locator + "\" not
found.").interval(step).timeout(ELEM_TIMEOUT).until(new Condition() {
+ public boolean isTrue() {
+ return selenium.isElementPresent(locator);
}
- try {
- if (selenium.isElementPresent(locator)) {
- break;
- }
- } catch (Exception e) {
- }
- waitFor(1000);
- }
+ });
}
/**
Show replies by date