wait for “loading” icon to disappear from the page

前端 未结 3 1393
不知归路
不知归路 2021-01-21 14:47

we are doing automation for web application and most of the scenario getting loading icon will appear at center of the page .. we need to wait for dis appear to loading icon

3条回答
  •  伪装坚强ぢ
    2021-01-21 15:16

    You can also wait till the ajax calls have been completed. Loading wheel disappears when all the ajax calls have completed (in most of the scenarios):

    WebDriverWait wait = new WebDriverWait(d, timeOutSeconds);
    wait.until(waitForAjaxCalls()); 
    
    public static ExpectedCondition waitForAjaxCalls() {
            return new ExpectedCondition() {
                @Override
                public Boolean apply(WebDriver driver) {
                    return Boolean.valueOf(((JavascriptExecutor) driver).executeScript("return (window.angular !== undefined) && (angular.element(document).injector() !== undefined) && (angular.element(document).injector().get('$http').pendingRequests.length === 0)").toString());
                }
            };
        }
    

提交回复
热议问题