Stop closing browser after each scenario cucumber

2,644 views
Skip to first unread message

Magesh Kumar

unread,
Jun 25, 2018, 5:19:54 PM6/25/18
to Cukes
Hi,

In my test case i have three scenarios to access web application and manipulate with it.

But  the browsers closed after each scenario.Can any one please let me know, how to stop closing the browser and use same browser instance for all the scenarios

Thomas Sundberg

unread,
Jun 26, 2018, 1:35:11 AM6/26/18
to Cukes
You are most likely calling browser.quit() or possible browser.close()
somewhere. The trick is not to do that until you are done using that
browser instance. Unfortunately, it is hard to say more without seeing
your code. Please share more details about your code and we might be
able to help you better. Details include the step from where you call
close() or quit() on your browser abstraction.

I your scenarios pass and your only problem is that the browser is
shut down between every execution, I would expect that the closing is
done either in your last then step or in an after hook.

Sorry for being vague, but without more details it is hard to be more concrete.
Thomas


> --
> Posting rules: http://cukes.info/posting-rules.html
> ---
> You received this message because you are subscribed to the Google Groups "Cukes" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Thomas Sundberg
M. Sc. in Computer Science

Mobile: +46 70 767 33 15
Blog: http://www.thinkcode.se/blog
Twitter: @thomassundberg

Better software through faster feedback

Koen Prins

unread,
Jun 30, 2018, 2:06:24 PM6/30/18
to cu...@googlegroups.com
I would even go further and say that it can be desirable to close the browser after a scenario to ensure a clean setup.
If you now run into the problem that your test is taking to long, you need to change the way you are automating your tests.
If you need the browser to stay open so you can share state between scenario's, well, don't do that.

Alexander Schikora

unread,
Apr 6, 2019, 3:23:08 AM4/6/19
to Cukes
Totally disagree. A Feature is not a Scenario for a reason. You obviously don't automate a lot. 

@Magesh Kumar: I would suggest to avoid Cucumber, it's outdated and too many people have too many options about what's right and whats not, see Koen here. Use Gauge and all your problems are gone.

Am Samstag, 30. Juni 2018 20:06:24 UTC+2 schrieb Koen Prins:
I would even go further and say that it can be desirable to close the browser after a scenario to ensure a clean setup.
If you now run into the problem that your test is taking to long, you need to change the way you are automating your tests.
If you need the browser to stay open so you can share state between scenario's, well, don't do that.

On Tue, Jun 26, 2018 at 7:35 AM Thomas Sundberg <t...@kth.se> wrote:
On Mon, 25 Jun 2018 at 23:19, Magesh Kumar <mageshk...@gmail.com> wrote:
>
> Hi,
>
> In my test case i have three scenarios to access web application and manipulate with it.
>
> But  the browsers closed after each scenario.Can any one please let me know, how to stop closing the browser and use same browser instance for all the scenarios
>

You are most likely calling browser.quit() or possible browser.close()
somewhere. The trick is not to do that until you are done using that
browser instance. Unfortunately, it is hard to say more without seeing
your code. Please share more details about your code and we might be
able to help you better. Details include the step from where you call
close() or quit() on your browser abstraction.

I your scenarios pass and your only problem is that the browser is
shut down between every execution, I would expect that the closing is
done either in your last then step or in an after hook.

Sorry for being vague, but without more details it is hard to be more concrete.
Thomas


> --
> Posting rules: http://cukes.info/posting-rules.html
> ---
> You received this message because you are subscribed to the Google Groups "Cukes" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to cu...@googlegroups.com.

> For more options, visit https://groups.google.com/d/optout.



--
Thomas Sundberg
M. Sc. in Computer Science

Mobile: +46 70 767 33 15
Blog: http://www.thinkcode.se/blog
Twitter: @thomassundberg

Better software through faster feedback

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cu...@googlegroups.com.

Jayson Smith

unread,
Apr 11, 2019, 1:45:06 PM4/11/19
to Cukes
Hi @Alexander Schikora,

What @Koen Prins said is quite accurate in more than just Cucumber's thoughts on test setup. While Gherkin follows the Given, When, Then idiom for its scenarios, this convention is not specific to Cucumber. In other testing environments it's also referred to as Arrange, Act, Assert. Ultimately, if you have tests that are bleeding context into one another, it makes both your positive and negative results potentially untrustworthy.

Cucumber isn't simply an automation tool and that they may be using it in ways that Gauge may not suit them if they were to switch. If you happen to feel that Gauge could help @Magesh Kumar's situation, then you're free to suggest that, however please do so as a respectful suggestion. Bashing Cucumber and making rude comments to/about other members is disrespectful and not allowed here. (It's also just not a great thing to do in general) If you're unsure about what is tolerated, feel free to review our Code of Conduct. Please also understand that everyone is allowed to have their own opinions and that in your statement, you too are expressing an opinion about what is right and what's not.

Thanks!

Js
Reply all
Reply to author
Forward
0 new messages