0

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?

4
  • This is quite related: sqa.stackexchange.com/questions/1988/… Commented Aug 10, 2015 at 15:08
  • @alecxe I did not understand what exactly they are trying to say. Some posts say that it is recommended to use a different browser window everytime. Other say use the same window. Can you please help me understand what should be done to run multiple tests? I have different classes for each test case and each of this class calls the methods in base class to run the test cases. Commented Aug 10, 2015 at 15:21
  • 2
    Well, it's definitely recommended to start each test with a clean browser session/state. Commented Aug 10, 2015 at 15:23
  • @alecxe Thanks! I will use the different browser windows to run multiple tests. Commented Aug 10, 2015 at 15:31

2 Answers 2

1
  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.

Sign up to request clarification or add additional context in comments.

Comments

0

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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.