Protractor — Session ID is null. Using WebDriver after calling quit()?

It will help you when using the tag restartBrowserBetweenTests

Túlio Bandeira Luz
1 min readAug 10, 2018

The problem:

I was suffering with a problem when I was running the tests in Protactor, in my structure containing pageobejct and cucumber. But the problem was that I using the tag “restartBrowserBetweenTests: true” on protractor.conf.js. When you had using this, the browser will be restarted every time that it will run and it lost the reference with test files, then it couldn’t interact with the page.

Just to remember you, if you use the tag “restartBrowserBetweenTests: true ”, this will cause your tests to slow down drastically.

The error:

org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?

The solution:

To solve this problem you have to do one function in an object to initialize the locators, that function must be called always you will run the test.

I created the module exports to object, this object has an one arrow function to initialize(lines 5~9) the locators to be used on the test.

Inside the Before(lines 8~10) I put the specPage.init(), this will call the initialize always the test will run.

That's works for me, thanks to read my post.

I wrote one post about how to run Protractor with PageObejct and Cucumber, if you need something about structure or some tips, just read.

Post: Automation with Protractor, PageObejct and Cucumber

My repository:

--

--

Túlio Bandeira Luz

I'm a QA Engineer, Computer Player, looking for another way to have fun and blink-182 fan. https://github.com/tuliobluz