量角器同步 - 超时

Protractor synchrozation - timeout

我正在编写简单的量角器测试四我们的应用程序:

当我想编写 angularhs 测试时 - 我遇到了这个错误(在 this 安装之后):

Timed out waiting for Protractor to synchronize with the page after 40002ms. Please see https://github.com/angular/protractor/blob/master/docs/faq.md

配置:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['login-spec.js'],
  baseUrl: 'https:/xyz/',
  allScriptsTimeout: 40000,

  capabilities: {
    'browserName': 'firefox'
  }
}

还有我的规格:

describe('Login #1', function() {
  // BEFORE LOGIN
  it('should pass to next login step', function() {
    browser.driver.get('https://xyz/login');
    browser.driver.findElement(by.css(".factorFirst > [name='username']:first-child")).sendKeys('123456');

    .... other login stuff

  }, 90000);

  // AFTER LOGIN TEST
  it('Simple Angular Test', function() {
    browser.get('/page');

    element(by.model('payment.userSpecified.message')).sendKeys(1);

  }, 45000);


});

我们的 body 元素属性中没有 ng-app。这会是个问题吗?

你需要让protractor知道登录页面是非angular的,不需要等待angular到"settle down"。在登录前将 ignoreSynchronization 设置为 true,并在

之后将其设置回 false
describe('Login #1', function() {

  afterEach(function () {
    browser.ignoreSynchronization = false;
  });

  it('should pass to next login step', function() {
    browser.ignoreSynchronization = true;

    browser.driver.get('https://xyz/login');
    browser.driver.findElement(by.css(".factorFirst > [name='username']:first-child")).sendKeys('123456');
  }, 90000);

  it('Simple Angular Test', function() {
    browser.get('/page');

    element(by.model('payment.userSpecified.message')).sendKeys(1);

  }, 45000);
});