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

How to stop the webdriver to close browser #1801

Closed
erdelyizsolt opened this issue Sep 10, 2019 · 13 comments
Closed

How to stop the webdriver to close browser #1801

erdelyizsolt opened this issue Sep 10, 2019 · 13 comments

Comments

@erdelyizsolt
Copy link

I want to stop closing the webdriver after the tests, there is any settings for that in the serenity.conf?
Right now i do not use the cucumber hooks, and during writing the test scenarios, i want to hang the driver before it close the browser....
Thanks!

@wakaleo
Copy link
Member

wakaleo commented Sep 10, 2019

You mean leave the browser open after the tests have finished?

@erdelyizsolt
Copy link
Author

You mean leave the browser open after the tests have finished?

Yes. I mean somewhere is a driver.quit, or driver.close function coded, and i want to suspend it, temporary. I do not found it (i use serenity.conf file, and extend the PageObject class for my page object files, if that info help)

@wakaleo
Copy link
Member

wakaleo commented Sep 10, 2019

This isn't currently supported, but if you want to propose a PR I'd be happy to review. But it is generally very hard knowing that you are finishing the last test, so you may end up with lots of open browsers.

@s-sunny
Copy link

s-sunny commented Dec 9, 2019

@wakaleo Is it implemented?

@wakaleo
Copy link
Member

wakaleo commented Dec 9, 2019

No

@ViorelD90
Copy link

Hello, this would be very useful indeed. @wakaleo Has it been implemented?

@alejandro9702
Copy link

is there are a posibilitty to close the browser inside a stepdefinition?, if' isn't , there is some way to execute or launch one browser for each row off data table in my feature?

I mean, one browser for each one these rows test

When que el usuario cano se autentica en la plataforma de comercios de zunify para crear una sucursal
  | nombreSucursal | telefono | direccion | codigoPostal | cuentaIban | contrasena |
  | antioquia      | 12348889 | antioquia | 05455        | aa         | Prueba123  |
  | bogota         | 12348880 | bogota    | 05453        | aa         | Prueba123  |
  | cartagena      | 12348881 | cartagena | 05454        | aa         | Prueba123  |
  | cartagena      | 12348882 | bello     | 05451        | aa         | Prueba123  |

@anuvyas
Copy link

anuvyas commented Jun 18, 2021

Hi,
I want to log-off from my application before driver.close() or quit() is performed. Since browser instance is closed without logging-off from my application after one test is over, so when new browser instance is invoked for next test run, login is restricted as per my application security policy. As it does not allow multiple or concurrent login from the same user.

Due this issue, I am not able to execute whole regression test suite in one go where multiple tests are performed with different browser instance. I also tried to setup "serenity.restart.browser.for.each=never" properly in serenity.conf . After this new browser window is not invoked for next test but log-off does happen.

So the question here is how can I add script for logging off before driver.close or quit()

Please help, Thanks

@wakaleo wakaleo closed this as completed Feb 12, 2022
@sumitsipu
Copy link

Is below requirement implemented??

I want to stop closing the webdriver after the tests, there is any settings for that in the serenity.conf?
Right now i do not use the cucumber hooks, and during writing the test scenarios, i want to hang the driver before it close the browser....
Thanks!

@wakaleo
Copy link
Member

wakaleo commented Jul 17, 2023

Create a class that implements AfterAWebdriverScenario, e.g.

public class AfterAWebScenarioEnds implements AfterAWebdriverScenario {
    @Override
    public void apply(EnvironmentVariables environmentVariables, TestOutcome testOutcome, WebDriver webDriver) {
        // DO SOMETHING HERE
    }
}

And add the package to the serenity.extension.packages property in your serenity.conf file, e.g.

serenity.extension.packages="net.serenitybdd.demos.todos.cucumber.steps"

@sumitsipu
Copy link

what exactly I need to write inside apply method because I want the browser to stay open and not be closed.
And if you can explain serenity.extension.packages more and what I need to write exactly will help a lot.

Beacause,
I copy pasted below line in serenity.config file but still the browser is getting closed.
serenity.extension.packages="net.serenitybdd.demos.todos.cucumber.steps"

Thanks in advance

@wakaleo
Copy link
Member

wakaleo commented Jul 17, 2023

Having the browser stay open is not currently supported. However if you need to do something with the browser before the test finishes and the browser closes, that is how you do it.

@sumitsipu
Copy link

Please introduce it. Thats very helpful in debugging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants