falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rag...@apache.org
Subject falcon git commit: FALCON-1318: Method waitForAngularToFinish() should be robust to unresponsive browser contributed by Raghav Kumar Gautam
Date Mon, 20 Jul 2015 21:09:53 GMT
Repository: falcon
Updated Branches:
  refs/heads/master 1b47d2e7f -> 5b4cf24b7


FALCON-1318: Method waitForAngularToFinish() should be robust to unresponsive browser contributed
by Raghav Kumar Gautam


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

Branch: refs/heads/master
Commit: 5b4cf24b745c9f04c102ed93004786eb608f46e3
Parents: 1b47d2e
Author: Raghav Kumar Gautam <raghav@apache.org>
Authored: Mon Jul 20 14:08:43 2015 -0700
Committer: Raghav Kumar Gautam <raghav@apache.org>
Committed: Mon Jul 20 14:08:43 2015 -0700

----------------------------------------------------------------------
 falcon-regression/CHANGES.txt                   |  2 ++
 .../ui/search/AbstractSearchPage.java           | 15 ++++++++++++--
 .../falcon/regression/ui/search/PageHeader.java | 21 +++-----------------
 3 files changed, 18 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/5b4cf24b/falcon-regression/CHANGES.txt
----------------------------------------------------------------------
diff --git a/falcon-regression/CHANGES.txt b/falcon-regression/CHANGES.txt
index 45be445..c00e66f 100644
--- a/falcon-regression/CHANGES.txt
+++ b/falcon-regression/CHANGES.txt
@@ -357,6 +357,8 @@ Trunk (Unreleased)
    FALCON-681 delete duplicate feed retention test from falcon regression (SamarthG)
 
   BUG FIXES
+   FALCON-1318 Method waitForAngularToFinish() should be robust to unresponsive browser (Raghav
Kumar Gautam)
+
    FALCON-1314 Unify handling of local files and directory (Raghav Kumar Gautam)
 
    FALCON-1278 Submitted entity properties must have unique names (Raghav Kumar Gautam)

http://git-wip-us.apache.org/repos/asf/falcon/blob/5b4cf24b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java
b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java
index b22fa1c..e7d1ca2 100644
--- a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java
+++ b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java
@@ -18,6 +18,9 @@
 
 package org.apache.falcon.regression.ui.search;
 
+import com.google.common.util.concurrent.SimpleTimeLimiter;
+import com.google.common.util.concurrent.TimeLimiter;
+import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.falcon.regression.core.enumsAndConstants.MerlinConstants;
 import org.apache.falcon.regression.core.util.TimeUtil;
 import org.apache.falcon.regression.ui.pages.Page;
@@ -33,6 +36,7 @@ import org.testng.Assert;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 
 
@@ -138,8 +142,15 @@ public abstract class AbstractSearchPage extends Page {
             + "(angular.element(document).injector().get('$http').pendingRequests.length
=== 0)";
         boolean isLoaded = false;
         for (int i = 0; i < PAGELOAD_TIMEOUT_THRESHOLD && !isLoaded; i++) {
-            final Object output = ((JavascriptExecutor) driver).executeScript(javaScript);
-            isLoaded = Boolean.valueOf(output.toString());
+            TimeLimiter timeLimiter = new SimpleTimeLimiter();
+            final JavascriptExecutor proxyJsExecutor =
+                timeLimiter.newProxy((JavascriptExecutor) driver, JavascriptExecutor.class,
10, TimeUnit.SECONDS);
+            try {
+                final Object output = proxyJsExecutor.executeScript(javaScript);
+                isLoaded = Boolean.valueOf(output.toString());
+            } catch (Exception e) {
+                LOGGER.info("Checking of pending request failed because of: " + ExceptionUtils.getFullStackTrace(e));
+            }
             LOGGER.info(i+1 + ". waiting on angular to finish.");
             TimeUtil.sleepSeconds(1);
         }

http://git-wip-us.apache.org/repos/asf/falcon/blob/5b4cf24b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
index 6524ccf..cb5bccf 100644
--- a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
+++ b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
@@ -20,11 +20,9 @@ package org.apache.falcon.regression.ui.search;
 
 import org.apache.falcon.regression.core.enumsAndConstants.MerlinConstants;
 import org.apache.falcon.regression.core.util.AssertUtil;
-import org.apache.falcon.regression.core.util.TimeUtil;
 import org.apache.falcon.regression.core.util.UIAssert;
 import org.apache.log4j.Logger;
 import org.openqa.selenium.By;
-import org.openqa.selenium.JavascriptExecutor;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.support.FindBy;
@@ -186,7 +184,9 @@ public class PageHeader {
     public void uploadXml(String filePath) throws IOException {
         final WebElement uploadEntityTextBox = uploadEntityBox.findElement(By.id("files"));
         uploadEntityTextBox.sendKeys(filePath);
-        waitForAngularToFinish();
+        //wait for alert
+        driver.findElements(
+            By.xpath("//div[@class='messages notifs' and contains(@style,'opacity') and not(contains(@style,'1;'))]"));
     }
 
     public ClusterWizardPage doCreateCluster() {
@@ -253,19 +253,4 @@ public class PageHeader {
         return loginPage;
     }
 
-    protected void waitForAngularToFinish() {
-        final String javaScript = "return (window.angular != null) && "
-            + "(angular.element(document).injector() != null) && "
-            + "(angular.element(document).injector().get('$http').pendingRequests.length
=== 0)";
-        boolean isLoaded = false;
-        for (int i = 0; i < AbstractSearchPage.PAGELOAD_TIMEOUT_THRESHOLD && !isLoaded;
i++) {
-            final Object output = ((JavascriptExecutor) driver).executeScript(javaScript);
-            isLoaded = Boolean.valueOf(output.toString());
-            LOGGER.info(i+1 + ". waiting on angular to finish.");
-            TimeUtil.sleepSeconds(1);
-        }
-        LOGGER.info("angular is done continuing...");
-    }
-
-
 }


Mime
View raw message