-
Notifications
You must be signed in to change notification settings - Fork 2.3k
When using ExpectedConditions after browser.restart(), getting "Driver does not have valid session ID" error #3881
Comments
The issue is that you shouldn't be saving a reference to var EC = protractor.ExpectedConditions; If you set |
Agree. EC has a reference back to the browser object. If the browser object goes away, the EC is no longer valid after the session quits. A work around, for now, would be to get the ExpectedConditions from the browser object:
|
Does it make sense to have |
^^^ Maybe we could make this as a breaking change in beta since ExpectedConditions is no longer static. @juliemr thoughts? |
Thanks a lot for your investigation, perhaps this will resolve some issues I had to comment out. I am using chat a like app to test, so I do have many browser instances... I will come back to you if this helped. |
Is this Fixed? |
Problem still occurs. I need to restart browser between 2 specific test cases and I'm not able to due to this issue. After restart page loads but error appears: -
|
Hi, i have same problem with 'restartBrowserBetweenTests' parameter and 'browser.restart()'. I check selenium logs and i have test cases + 1 selenium session. And of course "This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used." |
@wieta after some study I came to the source of issue which I think is common for most of users. To solve the issue, you must decache them (https://www.npmjs.com/package/decache) and then use "require" again and also agian initialize and define variables. For my project I created a common utility function which always returns new Page Object. After I restart the browser I use my function to re-load all Page Objects and now it works perfect. So your code logic should go like this:
My common utility function does steps 3 and 4. Bare in mind to split data from PO files. If you want to pass data from one spec to another, create a module which does only that task, So you don't have to decache it too. |
Hi there! I am facing a similar issue, when using browser.restart. In my case, a subsequent browser.wait call waits almost indefinitely, and times out after an obscene amount of time, although the page is loaded and visible the whole time. I perform the restart operation in the Before hook of Cucumber:
Followed by a Given, where I perform a browser.get, followed by a browser.wait, before interacting with my element:
It is seemingly getting stuck in the browser.wait call, and times out, after waiting for an enormous amount of time. |
same issue as mentioned above.
|
From azachar (copied from #3677)
Hi There,
I am getting a very similar issue still on the version 4.0.13, it happens sometimes...
the test opens the page and waits to have a certain part in the url using the function bellow, the tests are using
browser.restart()
in afterEach. Since I am using a random order of running, it happens only sometimes.I am getting this error:
The screenshot from this failure clearly shows that the page is fully loaded and has its content so I guess this might be a bug. I guess that is related to this issue too.
Anyway, thank you for your help.
Best regards,
Andrej
Here is the failing test case:
here is protractor.conf
The text was updated successfully, but these errors were encountered: