ScriptTimeoutError: Timed out - From: Task: Protractor.waitForAngular()

て烟熏妆下的殇ゞ 提交于 2020-01-04 06:03:46

问题


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

ScriptTimeoutError: Timed out

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

回答1:


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.



来源:https://stackoverflow.com/questions/44672875/scripttimeouterror-timed-out-from-task-protractor-waitforangular

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!