Author: lfryc(a)redhat.com
Date: 2009-12-02 07:14:25 -0500 (Wed, 02 Dec 2009)
New Revision: 16034
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/waiting/Wait.java
Log:
* selenium-testing-lib
- Wait.until() - javadoc completition and modification of Wait method to test conditions
on the start of the waiting loop
- getTextOrNull() - will throw original RuntimeException instead of nesting that exception
inside SeleniumException
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-12-02
07:41:13 UTC (rev 16033)
+++
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java 2009-12-02
12:14:25 UTC (rev 16034)
@@ -811,11 +811,11 @@
public String getTextOrNull(String locator) {
try {
return
selenium.getEval(format("selenium.getTextOrNull(\"{0}\")", locator));
- } catch (Exception e) {
+ } catch (RuntimeException e) {
if ("ERROR: Threw an exception: element is not
found".equals(e.getMessage())) {
return null;
}
- throw new SeleniumException(e);
+ throw e;
}
}
Modified:
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/waiting/Wait.java
===================================================================
---
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/waiting/Wait.java 2009-12-02
07:41:13 UTC (rev 16033)
+++
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/waiting/Wait.java 2009-12-02
12:14:25 UTC (rev 16034)
@@ -373,8 +373,28 @@
}
/**
- * Stars loop waiting to satisfy condition.
+ * <p>Stars loop waiting to satisfy condition.</p>
*
+ * <p>The condition will be tested</p>
+ *
+ * <ul>
+ * <li>on the start,</li>
+ * <li>every time interval after last try</li>
+ * <li>and also once after timeout when finishes interval since last try before
timeout.</li>
+ * </ul>
+ *
+ * <p>Scheme:</p>
+ *
+ * <p><pre>S ..int.. T ..int.. T ..int1..timeout..int2..
L</pre></p>
+ *
+ * <p>
+ * <div>S - starting try</div>
+ * <div>T - try within intervals</div>
+ * <div>L - last try after timeout</div>
+ * <div>int - one interval</div>
+ * <div>int = int1 + int2</div>
+ * </p>
+ *
* @param condition
* what wait for to be satisfied
*/
@@ -382,13 +402,17 @@
long start = System.currentTimeMillis();
long end = start + timeout;
while (System.currentTimeMillis() < end) {
+ if (condition.isTrue())
+ return;
try {
Thread.sleep(interval);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
- if (condition.isTrue())
- return;
+ if (System.currentTimeMillis() >= end) {
+ if (condition.isTrue())
+ return;
+ }
}
fail();
}
Show replies by date