Testing AngularJS with Selenium

后端 未结 12 729
梦毁少年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:40

    If you're using AngularJS then using Protractor is a good idea.

    If you use protractor you can use it's waitForAngular() method which will wait for http requests to complete. It's still good practise to wait for elements to be displayed before acting on them, depending on your language and implementation it might look this in a synchronous language

    WebDriverWait wait = new WebDriverWait(webDriver, timeoutInSeconds);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id));
    

    Or in JS you can use wait method which executes a function until it returns true

    browser.wait(function () {
        return browser.driver.isElementPresent(elementToFind);
    });
    

提交回复
热议问题