2017-09-27 72 views
0

我有以下代码:量角器执行挂起

it('Should be able to sign in', function() { 
    // Find page elements 
    var userNameField = browser.findElement(By.id('email')); 
    var userPassField = browser.findElement(By.id('password')); 
    browser.sleep('1000'); 
    var userLoginBtn = browser.findElement(By.id('loginbtn')); 

    // Fill input fields 
    userNameField.sendKeys('abc'); 
    userPassField.sendKeys('123'); 

    // Ensure fields contain what we've entered 
    expect(userNameField.getAttribute('value')).toEqual('abc'); 
    expect(userPassField.getAttribute('value')).toEqual('123'); 

    // Click to sign in 
    userLoginBtn.click(); 
    expect(browser.getCurrentUrl()).toMatch('/user/dashboard'); 
}); 

it('Should be able to logout', function() { 

    element(by.id('logout')).click(); 
    expect(browser.getCurrentUrl()).toMatch('/login'); 
}); 

的问题是,它没有达到第二“它”,但是失败:

Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular 
While waiting for element with locator - Locator: By(css selector, *[id="logout"]) 

如果我添加:

browser.waitForAngularEnabled(false); 

然后它继续进行最后的测试,它的工作原理,但这是正确的解决方案吗?

+0

尝试增加时间'allScriptsTimeout'关闭等待角在配置文件中有一些更高的值。 –

回答

0

是的,你必须禁用角,因为你正在使用browser.findElement(By.id('email'));我假设页面没有使用Angular;

如果您需要导航到不使用角一个页面,你可以通过设置`browser.waitForAngularEnabled(假)

Timeouts