Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restarting protractor browser between tests can cause issues #56

Closed
jan-molak opened this issue Jun 4, 2017 · 11 comments
Closed

Restarting protractor browser between tests can cause issues #56

jan-molak opened this issue Jun 4, 2017 · 11 comments
Labels
@serenity-js/protractor

Comments

@jan-molak
Copy link
Member

@jan-molak jan-molak commented Jun 4, 2017

It seems like restarting the protractor browser between tests can cause some issues:

  • an unnecessary browser session might get started after the test run is finished - #34, #43
  • the failing test might not get reported - #43

The possible root cause of those issues could be related to:

It would be great to get a reproducible scenario demonstrating this issue.

@BlacktoBlue
Copy link

@BlacktoBlue BlacktoBlue commented Jun 5, 2017

This appears to only happen in versions after 1.2.4.

Between the first and second scenario there is a browser instance opened then closed.

I have recreated this by pulling down 'tutorial-from-script-to-serenity' and changing serenity-js version to 1.3.0

@jan-molak
Copy link
Member Author

@jan-molak jan-molak commented Jun 7, 2017

So far it seems like Protractor will kill the browser and spawn a new one after every single test, including the last test, if the restartBrowserBetweenTests flag is set to true.
This results in an orphaned browser session that's spawned after the suite is executed.

I'm not yet sure if that's a problem with Protractor or with how Serenity/JS communicates with the Protractor Runner and Protractor afterEach hook. I need to investigate this further.

Update: Reported as angular/protractor#4315

Update 2: Looks like a Protractor issue to me, I can reproduce it with Serenity/JS, protractor-cucumber-framework and even the built-in Jasmine adapter; more details here.
I'm waiting for feedback from the Protractor team.

@BlacktoBlue
Copy link

@BlacktoBlue BlacktoBlue commented Jun 23, 2017

While this is getting investigated by the protractor team, is there a way to manually specify a beforeEach and AfterEach in serenity? would it be in the world.ts file?

@jan-molak
Copy link
Member Author

@jan-molak jan-molak commented Jun 23, 2017

Hey @BlacktoBlue, sure. You can do this using the standard mechanisms of either of the supported test runners: Mocha or Cucumber.

Here's an example of using an after hook with cucumber.

@jan-molak
Copy link
Member Author

@jan-molak jan-molak commented Sep 17, 2017

Looks like @darrinholst managed to work around this problem, we'll need something similar...

@hamber-dick
Copy link

@hamber-dick hamber-dick commented Oct 13, 2017

Any Progress on this? We're not able to run more than 2 Cucumber-Testscenarios without this errors:

(node:6644) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 40): NoSuchSessionError: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

NoSuchSessionError: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used. at WebDriverError (C:\Users\s.sander\workspace\connector-client-protractor\contentHubNG.E2E.Tests\node_modules\selenium-webdriver\lib\error.js:27:5) at NoSuchSessionError (C:\Users\s.sander\workspace\connector-client-protractor\contentHubNG.E2E.Tests\node_modules\selenium-webdriver\lib\error.js:122:5) at session_.flow_.promise (C:\Users\s.sander\workspace\connector-client-protractor\contentHubNG.E2E.Tests\node_modules\selenium-webdriver\lib\webdriver.js:856:16) at new ManagedPromise (C:\Users\s.sander\workspace\connector-client-protractor\contentHubNG.E2E.Tests\node_modules\selenium-webdriver\lib\promise.js:1067:7) at ControlFlow.promise (C:\Users\s.sander\workspace\connector-client-protractor\contentHubNG.E2E.Tests\node_modules\selenium-webdriver\lib\promise.js:2396:12) at promise.finally (C:\Users\s.sander\workspace\connector-client-protractor\contentHubNG.E2E.Tests\node_modules\selenium-webdriver\lib\webdriver.js:855:34) at promise.then.error (C:\Users\s.sander\workspace\connector-client-protractor\contentHubNG.E2E.Tests\node_modules\selenium-webdriver\lib\promise.js:1590:12) at ManagedPromise.invokeCallback_ (C:\Users\s.sander\workspace\connector-client-protractor\contentHubNG.E2E.Tests\node_modules\selenium-webdriver\lib\promise.js:1366:14) at TaskQueue.execute_ (C:\Users\s.sander\workspace\connector-client-protractor\contentHubNG.E2E.Tests\node_modules\selenium-webdriver\lib\promise.js:2970:14) at TaskQueue.executeNext_ (C:\Users\s.sander\workspace\connector-client-protractor\contentHubNG.E2E.Tests\node_modules\selenium-webdriver\lib\promise.js:2953:27) at asyncRun (C:\Users\s.sander\workspace\connector-client-protractor\contentHubNG.E2E.Tests\node_modules\selenium-webdriver\lib\promise.js:2813:27) at C:\Users\s.sander\workspace\connector-client-protractor\contentHubNG.E2E.Tests\node_modules\selenium-webdriver\lib\promise.js:676:7 at process._tickCallback (internal/process/next_tick.js:103:7)

@BlacktoBlue
Copy link

@BlacktoBlue BlacktoBlue commented Oct 16, 2017

@hamber-dick I have managed to work around this by setting restart between tests to false and following @jan-molak example posted above on 23rd of June.

@BlacktoBlue
Copy link

@BlacktoBlue BlacktoBlue commented Jan 12, 2018

@jan-molak has any progress been made on this?

@jan-molak
Copy link
Member Author

@jan-molak jan-molak commented Jan 21, 2018

@BlacktoBlue - looks like the protractor issues haven't been addressed and I didn't get a chance to look into any workarounds yet. Thoughts and PRs are welcome!

@jan-molak jan-molak added @serenity-js/protractor and removed ready labels Jul 26, 2018
@rajeshwarp
Copy link

@rajeshwarp rajeshwarp commented Oct 17, 2019

@jan-molak : For now do we have any workarounds/suggestion, that we can use with serenity-js

jan-molak added a commit that referenced this issue Jan 19, 2020
…ore starting a scenario

This is to align the behaviour with @serenity-js/jasmine and ensure restarting the browser when the
@serenity-js/cucumber module is combined with @serenity-js/protractor does not cause invalid
WebDriver session errors.

Closes #56
@jan-molak
Copy link
Member Author

@jan-molak jan-molak commented Jan 19, 2020

Version 2.0.1-alpha.107 should address the issue. Let me know what you think!

@jan-molak jan-molak removed the blocked label Jan 19, 2020
@jan-molak jan-molak added this to the 2.0 milestone Jan 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@serenity-js/protractor
Projects
None yet
Development

No branches or pull requests

4 participants