thomagron
thomagron

Reputation: 101

Selenium Webdriver continue through multiple classes

I made a test script that is way to long. So, i'm making short classes. if i want to run a few in a row (with TestNG xml file) the first class will succeed, but the next one opens a new firefox window because of:

WebDriver driver = new FirefoxDriver();    

How do I make it so that it won't open a new window but goes on in the same window as the previous class?

Upvotes: 0

Views: 918

Answers (2)

SacTan
SacTan

Reputation: 381

This might be workaround, you can used in you code, @AfterClass public closedBrowser() { driver.close(); }

So that next class is opened freshly in new browser. Write a 'driver.close()' in After class.

Upvotes: 2

Andrew Regan
Andrew Regan

Reputation: 5113

This has been answered many times before, but here is one I posted the other day. In a nutshell:

  • Create singleton WebDriver at the start of your test run
  • Reuse it in all your tests
  • Don't close or quit it until you're finished.

Upvotes: 2

Related Questions