Selenium WebDriver Tutorial #4 - How to Define Base Test Class

preview_player
Показать описание
Defining Base Test Class
================================
|- In Selenium Base class is the main class which takes care of Browser setup, loading configuration file and other reusable methods like screenshot, handling sync issues and many more.

|-With base class you can avoid code duplication and can reuse the code as much you want.

Example:
========
package base;
public class BaseTest {
public WebDriver webDriver;
public String browser="edge";
@BeforeTest
public void setUp() {
//set the ChromeDriver
//open the Browser
webDriver=new ChromeDriver();
}
//set the EdgeDriver
//open the browser
webDriver=new EdgeDriver();
}
//set up the FireFox Driver
//open the browser
webDriver=new FirefoxDriver();;
}
//Load a new web page in the current browser window
}
@AfterTest
public void tearDown() {
//close the browser
}
}
Рекомендации по теме