Created
September 4, 2015 07:07
Revisions
-
priyanshus revised this gist
Sep 4, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,6 +15,6 @@ public Boolean apply(WebDriver driver) { return ((JavascriptExecutor) driver).executeScript(javaScriptToLoadAngular).equals(true); } }; WebDriverWait wait = new WebDriverWait(driver, 20); wait.until(pendingHttpCallsCondition); } -
priyanshus created this gist
Sep 4, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ /** * Sometime it happens while automating the angular app, view gets loaded entirely but performing any action * on that view fails the test. This could happen because angular $http calls are still pending in backend. * We can have explicit wait in this way to ensure that angular has made all the $http calls. * Wait until angular finishes the $http calls while loading the view */ public void waitForAngular() { final String javaScriptToLoadAngular = "var injector = window.angular.element('body').injector();" + "var $http = injector.get('$http');" + "return ($http.pendingRequests.length === 0)"; ExpectedCondition<Boolean> pendingHttpCallsCondition = new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver driver) { return ((JavascriptExecutor) driver).executeScript(javaScriptToLoadAngular).equals(true); } }; WebDriverWait wait = new WebDriverWait(driver, timeout); wait.until(pendingHttpCallsCondition); }