Testing AngularJS with Selenium

后端 未结 12 723
梦毁少年i
梦毁少年i 2020-11-27 04:56

I have a SPA application on stack ASP MVC + AngularJS and I\'d like to test the UI. For now I\'m trying Selenium with PhantomJS and WebKit drivers.

This is a sample

12条回答
  •  遥遥无期
    2020-11-27 05:42

    I did the following code and it helped me for the async race condition failures.

    $window._docReady = function () {
            var phase = $scope.$root.$$phase;
            return $http.pendingRequests.length === 0 && phase !== '$apply' && phase !== '$digest';
        }
    

    Now in selenium PageObject model, you can wait for

    Object result = ((RemoteWebDriver) driver).executeScript("return _docReady();");
                        return result == null ? false : (Boolean) result;
    

提交回复
热议问题