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

Different Actors cannot be made to share same browser #989

Closed
nbarrett opened this issue Oct 26, 2017 · 9 comments
Closed

Different Actors cannot be made to share same browser #989

nbarrett opened this issue Oct 26, 2017 · 9 comments
Labels

Comments

@nbarrett
Copy link
Contributor

nbarrett commented Oct 26, 2017

I'm configuring my Screenplay environment using OnStage.setTheStage(new OnlineCast());, and then obtaining actor references usingOnStage.theActorCalled(<actor name>), however I find a new browser window is created for each actor, regardless of the value of property serenity.use.unique.browser. On the system under test, this actually causes problems with the running of the system. This behaviour can be reproduced in the todo demo project by:

  • setting the following configuration:
serenity {
  restart.browser.for.each = NEVER
  use.unique.browser = true
}
  • changing features/record_todos/add_new_items_to_the_todo_list.feature to
  Scenario: Adding an item to an empty list in Cucumber
    Given that James has an empty todo list
    Given that John has an empty todo list
    Given that Joe has an empty todo list
  • running net.serenitybdd.demos.todos.cucumber.RecordTodos

Outcome is that 3 browsers are fired up.

How can I ensure that all actors share the same browser please?

@nbarrett
Copy link
Contributor Author

nbarrett commented Oct 26, 2017

Actually, having played around with things, I can retrieve actors via a custom method like this:
theActorCalled(actorName).can(BrowseTheWeb.with(ThucydidesWebDriverSupport.getWebdriverManager().getWebdriverByName("same actor")));

But that seems like a hack - is there a better way than this?

@wakaleo
Copy link
Member

wakaleo commented Oct 30, 2017

The best way would be to write your own OnlineCast class, and hide this logic inside. Look at the implementation of the standard OnlineCast and go from there.

@wakaleo
Copy link
Member

wakaleo commented Nov 8, 2017

I'm assuming this question is answered?

@nbarrett
Copy link
Contributor Author

nbarrett commented Nov 8, 2017

I might submit a PR as the current behaviour is not as expected?

@wakaleo
Copy link
Member

wakaleo commented Nov 8, 2017

Sure, please do.

@wakaleo
Copy link
Member

wakaleo commented Nov 8, 2017

Which current behaviour is not as expected?

@nbarrett
Copy link
Contributor Author

nbarrett commented Nov 8, 2017

E.g serenity.use.unique.browser property should affect browser instantation, so my proposal would be to invoke the workaround code I suggested above if this property is set true.

@wakaleo
Copy link
Member

wakaleo commented Nov 8, 2017

Good point, but use.unique.browser is no longer used - it has been replaced by serenity.restart.browser.for.each

@nbarrett
Copy link
Contributor Author

nbarrett commented Nov 8, 2017

Okay, will do but I had serenity.restart.browser.for.each=NEVER set all along. However I thought that property was controlling browser restarts rather than browser instances which to me are different concerns (hence both properties). I've seen another issue where serenity.restart.browser.frequency was discussed as the deprecated property!

@wakaleo wakaleo closed this as completed Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants