You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2014/09/02 01:18:44 UTC

[4/6] git commit: Simplify waitForAjaxRequestsToComplete() to make it more stable & predictable

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 <hl...@apache.org>
Authored: Mon Sep 1 16:00:13 2014 -0700
Committer: Howard M. Lewis Ship <hl...@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;
             }