0

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?

Andrew Regan
  • 5,087
  • 6
  • 37
  • 73
thomagron
  • 101
  • 2
  • 12

2 Answers2

2

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.
Community
  • 1
  • 1
Andrew Regan
  • 5,087
  • 6
  • 37
  • 73
2

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.

SacTan
  • 379
  • 2
  • 5
  • 18