How to to run all the scenarios of one feature file in single browser instance - serenity-bdd

How to to run all the scenarios of one feature file in single browser instance. #After and#Before hooks instantiate after each scenario, Can't we execute them before all scenarios once and after all scenarios?

I assume when you say "single browser instance", you are talking about not restarting the browser between tests.
You need to add
serenity.restart.browser.for.each = feature
in your serenity.properties.

Related

How can I run test scenario in chrome using browser cache in karate?

I am testing a scenario in which I have to run chrome with cache so how can I do that as by default it launches browser without any cache.
This is not a normal requirement, but we have an option to set the userDataDir, here below is a screenshot from the documentation:
So if you know the path of a directory that exists, you can pass that. That said, maybe the correct testing strategy is to make a call 2 times and ensure that the second call is being cached. But some investigation may be required.

How to run all the scenarios of one feature file in single browser instance with selenium,serenity & cucumber

I am not able to execute selenium,cucumber & serenity scenarios of one feature file in single browser instance and currently each scenario is running in new browser instance
Below are my configurations:
Serenity and Cucumber version:
serenity.version=1.2.2-rc.1
serenity.cucumber.version=1.1.16
serenity.properties details:
serenity.use.unique.browser=true
restart.browser.each.scenario=false
Please let me know what other configuration i need to do to run all scenarios in one browser instance
serenity.use.unique.browser=true
serenity.restart.browser.for.each=STORY
(there can be also NEVER - for not closing browser even between Stories)
I've managed to add above and the SCENARIOS in one STORY would run without closing browser.
Check also if you have any Step that includes CLOSING the browser.
Take into account also what you have in #AfterStories and #AfterScenarios.

In testing an application, can I assume a previous test will pass in other tests?

I am testing the functionality of an application. One of the tests is to verify that the application can connect to an external source. The rest of the tests require that the application is connected. Is it all right to write a test to test for the application's ability to connect and then the other tests to assume the application can connect and have one of the test steps as "Connect to External source"?
Thanks.
This should be considered on test by test basis. You can skip that assertion unless it's going to complicate interpreting the results of the tests a lot.
There is an even better way - you can implement a /health endpoint in the application itself. It could invoke all its dependencies and return 200 OK if everything is okay and 500 if not. Your deployment scripts could hit that endpoint. Therefore this becomes a post-deployment check instead of a functional test. So you won't even start running your tests if one of the dependencies is down.

Webdriverio (WDIO) and Cucumber Browser based on Tag

How would one setup WDIO to run a scenario on a specific browser based on a cucumber tag. I think I can do it by closing the existing browser instance and then opening a new browser instance in a cucumber before scenario hook, but that is not efficient.
When you define your browser configuration, you can specify certain test to run in that browser only.

Nightwatch.js - Use the same browser session

We would love to adopt Nightwatch.js for testing on browsers, but we're stuck on one major caveat: at the time of this writing, Nightwatchjs does not support running different tests using the same browser session. In short, it means that:
Creating the browser session is handled by the Nightwatch module from lib/index.js, in the startSession function;
Killing the browser would correspond to the delete command place in the Selenium action queue in the terminate function of that module;
A new Nightwatch client is created at every test run, which happens every time we load a different test file;
According to this source, it is possible to reuse the current browser session in Selenium, instead of opening a new window.
Has anyone managed to fix this problem in Nightwatch?
Here's the feature request on Github, which was requested on Mar 31, 2014 and is still open.
Another approach would be to circumvent the problem altogether by getting Nightwatch to merge all different files into one Test Suite, but that seems to be harder to solve than the problem with sessions...
Nightwatch now has support for resuing browser sessions. You can simply use the flag --reuse-browser to reuse sessions while running your nightwatch tests.