angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

A Jasmine Spec has timed out: Resetting the webdriver control flow #1095

Closed illninofan closed 10 years ago

illninofan commented 10 years ago

Hi

I'm pretty new to protractor and currently using version 1.0.0-rc4

When I've got multiple specs, and I run them via protractor config.js, I get the following error

A Jasmine Spec has timed out: Resetting the webdriver control flow

with the first spec passing (logging into the website) but the next spec failing with the above line in the command prompt

Any ideas?

juliemr commented 10 years ago

Your second spec timed out - there are many possible reasons for this. Check out https://github.com/angular/protractor/blob/master/docs/timeouts.md

illninofan commented 10 years ago

Hi @juliemr

Thanks alot for your reply :)

I've looked over the timeout page and can't seem to think where my issue applies

My config.js is as follows:

// conf.js

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js','fileupload.js'],
allScriptsTimeout: 20000,

// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 100000,
isVerbose: true
 }
};

Here are both of my Jasmine tests

// spec.js

describe('Site login', function () {
it('should login', function () {
browser.driver.get('http://mysite.co.uk');
browser.driver.findElement(by.name('UserName')).sendKeys('user');
browser.driver.findElement(by.name('Password')).sendKeys('xpassword');
browser.driver.findElement(by.id('logIn')).click();

expect(browser.driver.findElement(by.id('topUsername')).getText()).toContain('user');
    });
});

// File Upload spec

describe('File Upload', function() {
it('should upload a file', function () {
browser.driver.get('http://mysite.co.uk');
browser.driver.findElement(by.name('UserName')).sendKeys('user');
browser.driver.findElement(by.name('Password')).sendKeys('xpassword');
browser.driver.findElement(by.id('logIn')).click();

browser.driver.findElement(by.id('upload')).click(); 
browser.driver.findElement(by.name('FileToUpload')).sendKeys("C:\\myfile.csv"); 
browser.driver.findElement(by.xpath('html/body/div[1]/div[7]/div[2]/div/button[2]/span')).click(); 
console.log('file has been uploaded');
    });
});
juliemr commented 10 years ago

Can you try upgrading to 1.0? There was an issue with timeouts being reported when they shouldn't that has been fixed.

illninofan commented 10 years ago

Yes I upgraded to 1.0 and it's working now :)

Thanks so much for this great tool

Sent From The NetherRealm On 23 Jul 2014 19:03, "Julie Ralph" notifications@github.com wrote:

Can you try upgrading to 1.0? There was an issue with timeouts being reported when they shouldn't that has been fixed.

— Reply to this email directly or view it on GitHub https://github.com/angular/protractor/issues/1095#issuecomment-49911554.

juliemr commented 10 years ago

Great!

gvhelp commented 9 years ago

I got the same issue : A Jasmine spec timed out. Resetting the WebDriver Control Flow. The last active task was:

I am using C:\Dev\test>protractor --version Version 1.8.0

Any suggestion!?

d3day commented 9 years ago

protractor 1.8.0 same issue with firefox. about every 10th run is failing due to this timeout error

AksimO commented 9 years ago

Same issue chrome. Every 10th test failing with timeout error. (I run same test suite 20 times, got 2 timeout errors in a console). It might be important that restartBrowserBetweenTests: true, I also don´t wait angular to load, I use browser.driver.get, but I don't see 10th request in webdrive logs.

   { applicationCacheEnabled: false,
     rotatable: false,
     mobileEmulationEnabled: false,
     chrome: { userDataDir: 'C:\\Users\\RRRR~1\\AppData\\Local\\Temp\\scoped_dir10544_2327' },
     takesHeapSnapshot: true,
     databaseEnabled: false,
     handlesAlerts: true,
     version: '42.0.2311.152',
     platform: 'XP',
     browserConnectionEnabled: false,
     nativeEvents: true,
     acceptSslCerts: true,
     'webdriver.remote.sessionid': '6266fa7f-c8c1-4645-8911-adf4ed8a9503',
     locationContextEnabled: true,
     webStorageEnabled: true,
     browserName: 'chrome',
     takesScreenshot: true,
     javascriptEnabled: true,
     cssSelectorsEnabled: true } }
AksimO commented 9 years ago

I checked it on 3 different windows machine. Simplest test that fails for me(with restartBrowserBetweenTests: true) is:

for (var i = 0; i <22 ; i ++) {
  (function (i) {
  describe('Test session', function () {
    it('Test', function () {
      console.log('i=', i);
      browser.driver.get('data:text/html,lots of text...');
      expect(true).toBe(true);
    });
  });
  })(i);
}

It looks like something wrong with newSession. It does not start new session for test N10 and N20 Protractor version Version 2.0.0.

AksimO commented 9 years ago

I found that it's problem in jasminewd2. For some reason it starts suite 10 before suite is finished. Workaround to use jasminewd instead of jasminewd2. In order to do it put in protractor config framework: 'jasmine' instead of framework: 'jasmine2'.

bitliner commented 9 years ago

Same issue here, testing on IE9 inside a VM. Sometimes it fails (timeout), sometimes it doesn't.

TypeError: Cannot call method 'split' of undefined
    at Object.SpecDisplay.filterStackTraces (/app/node_modules/jasmine-spec-reporter/src/spec-display.js:110:24)
    at Object.SpecDisplay.displayErrorMessages (/app/node_modules/jasmine-spec-reporter/src/spec-display.js:102:25)
gologox commented 9 years ago

Same issue here. If you follow AksimO's suggestion above, it fixes the issue: 'jasmine' instead of framework: 'jasmine2'.

bitliner commented 9 years ago

It is already 'jasmine'. Unfortunately i dont have more details. I'll post more as soon as i have them.

On Friday, May 29, 2015, gologox notifications@github.com wrote:

Same issue here. If you follow AksimO's suggestion above, it fixes the issue: 'jasmine' instead of framework: 'jasmine2'.

— Reply to this email directly or view it on GitHub https://github.com/angular/protractor/issues/1095#issuecomment-106613486 .

Giovanni Gaglione

LinkedIn: http://lnkd.in/MyZGut Telefono: +39 388 - 82.6666.2 / 0031-06.49.75.66.93 / 0031-06.11.06.22.17 Email: giovanni.gaglione@gmail.com giovanni.gaglione@gmail.comSkype: bitliner

AksimO commented 9 years ago

Hint.

File jasmine-core/lib/jasmine-core/jasmine.js contains constant var maximumSpecCallbackDepth = 20; and method QueueRunner.prototype.run. Method QueueRunner.prototype.run clearStack runs callback 9 times sync, then it wraps callback in a setTimeout(..., 0);. Because of this callback is triggered async, jasmine runs next spec before webdriver quite current session => webdriver does not start new session => jasmines show timeout error.

rodrigomf24 commented 9 years ago

I don't know if this is a good solution but I noticed some of the requests on my angular app took a bit longer than 30000ms, so I changed in the config file " jasmineNodeOpts:{defaultTimeoutInterval: 60000} " to be 60000ms. Now it works perfectly and I don't get timeout errors.

calystoramesh commented 8 years ago

I got the same issue : A Jasmine spec timed out. Resetting the WebDriver Control Flow. tried this solution following solution :

  1. " jasmineNodeOpts:{defaultTimeoutInterval: 60000} " to be 60000ms. - not works
  2. 'jasmine' instead of framework: 'jasmine2'. ..In my Test script I am using beforeAll , afterAll not possible go to do the solution

Protractor version 2.5.1 please provide any other solution? thanks in advance

AksimO commented 8 years ago

Do see timeout message every time, or some of tests a passing?

calystoramesh commented 8 years ago

some of the test passed then occurs this error

AksimO commented 8 years ago

@calystoramesh, I had similar issue, I solved in with monkey patch. Find in jasmine-core/jasmine.js this line https://github.com/jasmine/jasmine/blob/master/lib/jasmine-core/jasmine.js#L660

change variable maximumSpecCallbackDepth to 2000 does it have any effect for you?

arturskeeled commented 8 years ago

None of this has worked. I am running in IE11 and no test passes. Any news here?

christoforosl commented 8 years ago

@arturskeeled , was having this issue in IE11, tests were passing in chrome, but not in ie11. Managed to make tests work. Only change was setting jasmineNodeOpts.defaultTimeoutInterval to 20000 (was 2000) in protractor config.
Changing maximumSpecCallbackDepth did not have any effect.

Edit: In addition to the above, I found that chrome is very forgiving with protractor promises. This is a result (I think) of the quickness with which Chrome executes and returns promises. For example, while the code below was happily working in chrome, it failed in IE:

var numberField2 = element(by.id('editRecord.numberField2'));
numberField2.sendKeys('12');
numberField2.clear();
protractorUtils.checkForNoError(numberField2); // not a required field

Reworked for IE:

var numberField2 = element(by.id('editRecord.numberField2'));
numberField2.sendKeys('12').then(function () {
        numberField2.clear().then(function () {
                protractorUtils.checkForNoError(numberField2); // not a required field
        });
});

Unrelated: WE HAVE to find a way to make asynchronous programming less verbose. How many "then(function () {}" can you write?

arturskeeled commented 8 years ago

@christoforosl Changing the webdriver from x64 to x32 worked for me. Although a couple days later i had to change it back to x64, and i found that out by pure chance. Hope it doesn't break again.

Thanks, but I guess my issue was another one, because I had changed "defaultTimeoutInterval" to 120'000 and it still didn't work.

makwanaparth94 commented 7 years ago

Getting the same error. I am also attaching a screenshot of it . Let me know the solutions of it Its an issue of my local machine requirement or a code issue?

Sometimes Script run on IE browser with their 3 instance and sometimes its not ruuning.

image image

gologox commented 7 years ago

I ended up just updating Protractor to the latest version and my Selenium server and everything is great

On May 17, 2017 2:51 AM, "makwanaparth94" notifications@github.com wrote:

Getting the same error. I am also attaching a screenshot of it . Let me know the solutions of it Its an issue of my local machine requirement or a code issue?

Sometimes Script run on IE browser with their 3 instance and sometimes its not ruuning.

[image: image] https://cloud.githubusercontent.com/assets/28529639/26148470/593fb5c4-3b14-11e7-90e9-b27d2cc82c79.png [image: image] https://cloud.githubusercontent.com/assets/28529639/26148483/620fdd6e-3b14-11e7-8170-41d6a70af963.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/protractor/issues/1095#issuecomment-302042506, or mute the thread https://github.com/notifications/unsubscribe-auth/AH6tn8D_UJtBUpWx95TRMVWqE-QFNpTwks5r6sMigaJpZM4CPFEf .

suzy123 commented 7 years ago

I have upgraded the protractor version,node,selenium server as well. Still facing the same issue.Can anyone provide any solution??

gologox commented 7 years ago

@suzy123 what is your jasmineNodeOpts.defaultTimeoutInterval set to? Mine is set to 260000, equivalent to 260 seconds.

{ seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: [ '/Users/**/**/**/automation/angular_automation/scripts/web/web_auto_delivery/web_auto_delivery.js' ],
  capabilities: 
   { platform: 'MAC',
     browserName: 'chrome',
     chromeOptions: { prefs: [Object] } },
  onPrepare: [Function: onPrepare],
  jasmineNodeOpts: { defaultTimeoutInterval: 260000 } }

I am also using Protractor Version 4.0.11 and Selenium 3.3.1

That's all I have, hope it helps with the issue.

suzy123 commented 7 years ago

Thanks. My issue has been resolved. I was using very large value in defaultTimeoutInterval which was causing problem.

makwanaparth94 commented 7 years ago

Scenario in my case is: Currently I automate a site using a protractor but that site also consumes swagger ui api.So my question is can we do automation of protractor using those api?

alejovicu commented 7 years ago

I'm getting the same issue "A Jasmine spec timed out. Resetting the WebDriver Control Flow." When I run spec by spec everything works as expected. But, when I run all the regression some tests fail randomly. I already changed the jasmine.DEFAULT_TIMEOUT_INTERVAL to 10 minutes but still failing for suites that executed individually takes just less than a minute.

vlad-danaila commented 7 years ago

Hello, I am using Protractor. I get the same issue when testing on IE, for Chrome and Firefox it works fine. I used some speciffic configurations for IE in order to make it work. Please find below the my conf.js file:

exports.config = { framework: 'jasmine', seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['<>'], multiCapabilities: [ { browserName: 'chrome' }, { browserName: 'firefox' }, { browserName: 'internet explorer', browserAttachTimeout: 10000, initialBrowserUrl: '<>' } ] };

Please keep in mind you need to previously have drivers downloaded for each browser. You do that using the selenium webdriver-manager. Protractor has its own in node-modules/webdriver-manager.

haroldvandy2013 commented 5 years ago

I'm getting the same issue "A Jasmine spec timed out. Resetting the WebDriver Control Flow." When I run spec by spec everything works as expected. But, when I run all the regression some tests fail randomly. I already changed the jasmine.DEFAULT_TIMEOUT_INTERVAL to 10 minutes but still failing for suites that executed individually takes just less than a minute.

Hi, I recently have same issue as yours, did you figure out the fix ?

Aswini2205 commented 4 years ago

Hi, I also have a similar issue. Any update?