tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject [4/6] git commit: Simplify waitForAjaxRequestsToComplete() to make it more stable & predictable
Date Mon, 01 Sep 2014 23:18:44 GMT
Simplify waitForAjaxRequestsToComplete() to make it more stable & predictable


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/014d7391
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/014d7391
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/014d7391

Branch: refs/heads/master
Commit: 014d7391c801a8506e76a6fdd058714da8b7a1d6
Parents: 3475b4d
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Mon Sep 1 16:00:13 2014 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Mon Sep 1 16:00:13 2014 -0700

----------------------------------------------------------------------
 .../apache/tapestry5/test/SeleniumTestCase.java   | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/014d7391/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
----------------------------------------------------------------------
diff --git a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
index b0b2020..fda70c5 100644
--- a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
+++ b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
@@ -1733,21 +1733,27 @@ public abstract class SeleniumTestCase extends Assert implements Selenium
 
     /**
      * Waits until all active XHR requests (as noted by the t5/core/dom module)
-     * have completed.  Waits up to 500 ms.
+     * have completed.
      *
      * @since 5.4
      */
-    protected final void waitForAjaxRequestsToComplete() {
-        for (int i = 0; i < 6; i++)
+    protected final void waitForAjaxRequestsToComplete()
+    {
+        // Ugly but necessary. Give the Ajax operation sufficient time to execute normally,
then start
+        // polling to see if it has complete.
+        sleep(250);
+
+        // The t5/core/dom module tracks how many Ajax requests are active
+        // and body[data-ajax-active] as appropriate.
+
+        for (int i = 0; i < 10; i++)
         {
             if (i > 0)
             {
                 sleep(100);
             }
 
-            // The t5/core/dom module tracks how many Ajax requests are active
-            // and updates this property as appropriate.
-            if (getAttribute("//body/@data-ajax-active").equals("false"))
+            if (getCssCount("body[data-ajax-active=false]").equals(1))
             {
                 return;
             }


Mime
View raw message