Ketan Deopujari
Ketan Deopujari

Reputation: 113

Using the same Firefox Window to run multiple tests in Selenium WebDriver (Java)

I am running test cases on selenium Webdriver in Java. The first test case opens the browser window and performs the test.

After the first test case is complete I want to utilize the same browser window to run the next set of multiple test cases.

How can this be achieved? Can someone point me in right direction?

Upvotes: 0

Views: 1837

Answers (2)

Shamsur Rahim Hemel
Shamsur Rahim Hemel

Reputation: 47

  1. Don't quit your browser in the "TearDown" part.
  2. Navigate to a common URL in the "TearDown" part from where multiple test cases can start.

Thus you will be able to utilize the same browser window to run the next set of multiple test cases.

Upvotes: 1

Alex Collins
Alex Collins

Reputation: 1016

You can reuse a browser in multiple tests using Spring to inject it. This can be faster for running a suite. But, and it's a big but, if one tests "dirties" the browser (e.g. with cookies), then you could easily find yourself spending more time debugging flaky tests that you save on run time.

There's an example here: http://www.alexecollins.com/tutorial-integration-testing-selenium-part-1/

Upvotes: 0

Related Questions