Reputation: 93
How to implement the DriverSetup class in Selenium Webdriver framework.. Currently I am launching driver in @BeforeClass for each testng test class, please let me know if how can I implement the common driverLaunch/driverSetup class for all test Thanks in Advance..
Upvotes: 0
Views: 1806
Reputation: 3649
Did u mean a common setup for all classes? If so create a base class and extend it in every test class. In Base class have @BeforeClass to do the required. It would be somewhat like:
public class BaseClass {
WebDriver driver;
@BeforeClass
public void setUp() {
driver = new FirefoxDriver(); // or any driver u want, or based on requirement create a if else scenario
}
}
And in Testclass do like:
public class TestClass extends BaseClass {
// your class body with tests here
}
So whenever u run ur tests through testng it will call the setUp method in BaseClass and setup browser for u.
Upvotes: 1
Reputation: 3628
Init your WebDriver in @BeforeTest or in @BeforeSuite and close it in @AfterTest or @AfterSuite. So in this case every test method will get run in the same browser.
Upvotes: 1