Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS量角器:在无头模式下随机失败(Firefox)_Javascript_Angularjs_Firefox_Selenium Webdriver_Protractor - Fatal编程技术网

Javascript AngularJS量角器:在无头模式下随机失败(Firefox)

Javascript AngularJS量角器:在无头模式下随机失败(Firefox),javascript,angularjs,firefox,selenium-webdriver,protractor,Javascript,Angularjs,Firefox,Selenium Webdriver,Protractor,这是我的conf文件 exports.config = { rootElement: '[ng-app="myapp"]', framework: 'jasmine', seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['./web/assets/e2e/**/*protractor.js'], SELENIUM_PROMISE_MANAGER: false, baseUrl: 'https://localh

这是我的conf文件

exports.config = {
  rootElement: '[ng-app="myapp"]',
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['./web/assets/e2e/**/*protractor.js'],
  SELENIUM_PROMISE_MANAGER: false,
  baseUrl: 'https://localhost',
  capabilities: {
    browserName: 'firefox',
    marionette: true,
    acceptInsecureCerts: true,
    'moz:firefoxOptions': {
      args: ['--headless'],
    },
  }
}
因此,使用此配置,我的测试会随机失败,并出现以下错误

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
但是!当我注释掉下面几行时

    'moz:firefoxOptions': {
      args: ['--headless'],
    },
它代表headless模式,并观察firefox如何运行我的测试——测试从不失败,而且花费的时间少3倍

下面是一个由于我上面提到的错误而失败了几次的测试示例

  it('- should test add button open a form', async () => {
    await ClientListPageDriver.openAddClientForm();

    await FormDriver.toBeShown('Add New Client');

    await FormDriver.pressClose();
  });
下面是我引用的驱动程序的方法

  this.openAddClientForm = async () => {
    const button = await $('button[ng-click="$ctrl.addClient()"]');
    await button.click();
  };

  this.toBeShown = async (title) => {
    const modalElement = await $('#form').element(by.cssContainingText('.form-header h2', title))

    const awaitSeconds = 6;
    return await browser.wait(
      protractor.ExpectedConditions.presenceOf(modalElement),
      awaitSeconds * 1000,
      `Form should be shown within ${awaitSeconds} sec`,
    );
  };

  this.pressClose = async () => {
    const button = await $('button[ng-click="$ctrl.closeForm()"]');
    await button.click();
  };

我的问题是——我做错了什么,我可能遗漏了什么,我如何修复它?谢谢

将以下代码添加到配置中

allScriptsTimeout: 20000,
    jasmineNodeOpts: {
    defaultTimeoutInterval: 100000
     }
根据测试执行时间调整超时间隔。 有关更多信息,请参阅

希望对你有帮助