量角器同步-超时

Protractor synchrozation - timeout

本文关键字:超时 同步 量角器      更新时间:2023-09-26

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

  • 登录页面没有angularhs -工作正常
  • 所有其他页面都使用angularjs

当我想写angularhs测试-我得到了这个错误(以下安装):

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'
  }
}

And my spec:

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"安定下来"。登录前将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);
});