本文介绍了ScriptTimeoutError:超时 - 来自:任务:Protractor.waitForAngular()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行使用量角器编写的基本端到端测试.我总是收到这个错误.

ScriptTimeoutError:超时

我检查了这个链接 配置文件

exports.config = {框架:'茉莉花2',seleniumAddress: 'http://localhost:4444/wd/hub',规格:['test/e2e/menu.js'],能力:{'浏览器名称': '火狐',},baseUrl: 'http://localhost:8100/#/',//allScriptsTimeout: 360000,茉莉花节点选项:{显示颜色:真实,//默认超时间隔:360000},//useAllAngular2AppRoots:true,//menu.js描述('菜单检查',函数(){beforeEach(函数(){browser.get('http://localhost:8100/#/');browser.waitForAngular();//browser.driver.manage().timeouts().setScriptTimeout(60000);});it('应该从菜单路由到操作视图页面', function () {element(by.css('[href="#/operationalView"]')).click();期望(browser.getCurrentUrl()).toMatch('http://localhost:8100/#/operationalView');});it('应该从菜单路由到世界观页面', function () {element(by.css('[href="#/worldView"]')).click();期望(browser.getCurrentUrl()).toMatch('http://localhost:8100/#/worldView');});});
解决方案

我曾经遇到过这个问题,我使用

解决了这个问题

browser.ignoreSynchronization=true

在量角器规范文件中的 beforeEach() 方法之前.这使得 Protractor 不会等待 Angular 承诺,例如来自 $http$timeout 的承诺来解决.您可以在脚本中尝试此操作.

截至 2019 年 8 月 16 日,此解决方案已被弃用.使用 waitForAngularEnabled 改为 false.

I am trying to run basic end to end tests written using protractor. I always get this error.

I checked this link https://github.com/angular/protractor/blob/master/docs/timeouts.md and increased the default timeout, but still I get the same error. I am not able to figure out from where this error pops out. The browser loads the base Url, later it will not perform any action as mentioned in the test. The test is very simple , open the browser and click on the menu and verify if the URL is matched.

  • Node Version: v7.5.0
  • Protractor Version: 5.1.2
  • Angular Version: 2.4.10
  • Browser(s): firefox
  • Operating System and Version ubuntu
  • typescript: 2.2.2

Config file

 exports.config = {
      framework: 'jasmine2',    
      seleniumAddress: 'http://localhost:4444/wd/hub',
      specs: ['test/e2e/menu.js'],
      capabilities: {
        'browserName': 'firefox', 
    },
    baseUrl: 'http://localhost:8100/#/',
    //allScriptsTimeout: 360000, 
      jasmineNodeOpts: {
       showColors: true,
      // defaultTimeoutInterval: 360000
     },
    //useAllAngular2AppRoots:true,

//menu.js
describe('menu check', function () {
   beforeEach(function () {
        browser.get('http://localhost:8100/#/');
      browser.waitForAngular();
     // browser.driver.manage().timeouts().setScriptTimeout(60000);
   });

    it('Should route to the operationalView page from menu', function () {
       element(by.css('[href="#/operationalView"]')).click();
       expect(browser.getCurrentUrl()).toMatch('http://localhost:8100/#/operationalView');
    });

    it('Should route to the worldlview page from menu', function () {
        element(by.css('[href="#/worldView"]')).click();
        expect(browser.getCurrentUrl()).toMatch('http://localhost:8100/#/worldView');
    });
});
解决方案

I have had this issue once, which I resolved using

browser.ignoreSynchronization=true

before the beforeEach() method in your Protractor spec files. This makes Protractor not wait for Angular promises, such as those from $http or $timeout to resolve. You can try this in your script.

Edit : As of today, 08/16/19, this solution has been deprecated. Use waitForAngularEnabled to be false instead.

这篇关于ScriptTimeoutError:超时 - 来自:任务:Protractor.waitForAngular()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 11:20