6
votes

Hoping someone can help me out on this, as i've been searching around for days with no success

I'm currently attempting to use Protractor for e2e testing of an AngularJS application

I've got Protractor setup and running a test, however when I have more than one test / spec, the first test runs and then errors out with the following on the command line:

A Jasmine spec timed out. Resetting the WebDriver Control Flow. The last active task was: unknown

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

        browser.close();
    });
});

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

Any help would be greatly appreciated

P.S apologies if I've formatted anything wrong, first time poster :)

Edit: Issue resolved by updating to Protractor v1.0.0 via npm update

Thanks a lot for everyone's help :)

2
try to disable this line browser.close(); You closed your test browser, then the next test doesnot have any browser to run. - Nguyen Vu Hoang
Hi @NguyenVuHoang thanks alot for your reply, i've taken out the browser.closes() and am still seeing the same issue :( - GhostCore
do 3 files conf.js, fileupload.js and spec.js place at the same location? I've just try to re-run your scripts Finished in 1.799 seconds 2 tests, 0 assertions, 0 failures - Nguyen Vu Hoang
Yes, they are in the same location. Hmm that's really strange that you are able to run them and i'm not, do you get the Jasmine error message about Jasmine spec timed out? - GhostCore
nope :(, however, I deleted everything in your script content since I'm not able to access "mysite.co.uk". - Nguyen Vu Hoang

2 Answers

1
votes

refer to framework: 'jasmine2',

this to your protractor config i've been having the same issue for days! lemme know if it helps!

1
votes

You can add this code to your config file conf.js or otherName.js

    // Options to be passed to Jasmine-node
JasmineNodeOpts: {
    onComplete: null,
    // if true, print colors to the terminal
    showColors: true,
    // if true display spec Name
    isVerbose: false,
    silent: true,
    // if true, include stack traces in failures
    includeStackTrace: true,
    // default time to wait in ms before a test fails
    defaultTimeoutInterval: 30000,
    print: function() {}
},