Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making driver not to quit between tests in protractor

Tags:

protractor

there are two it() testcases in protractor

it('it1',function(){

});
it('it2',function(){

});

does the driver in protractor quits after completing it1?

Can we make protractor not to quit the driver?

like image 253
S Pat Avatar asked Nov 09 '22 12:11

S Pat


1 Answers

Take this example and let Protractor run it for you:

describe('describe1', function () {
    it('it1', function () {
        browser.get('http://www.angularjs.org');
    });
    it('it2', function () {
        element(by.linkText('View on GitHub')).click();
        browser.sleep(3000); // Here you should se that you are now on GitHub
    });
});

You should notice that it2 operates on the same driver. These two specs are both successful and couldn't be that if the browser quit in between the specs. We could add an afterEach where in we do a browser.quit() to prove that. The output of adding that afterEach is:

Error: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

This should prove that the browser isn't quitted in between specs. The driver is quitted on the end of all suites though. But at that point you are already finished with all interactions.

like image 65
Olov Avatar answered Jan 04 '23 02:01

Olov