Create DriverManager class to create a instance for Various Drivers like chromderiver, firefoxdriver
Hi All,
Today we are continuing with what is DriverManager Class and what is the responsibility of this class.
DriverManager is abstract class .
Here ThreadLocal<RemoteWebDriver> driver is a static ThreadLocal variable that stores the RemoteWebDriver instance.
A ThreadLocal allows each thread to have its own copy of the variable, ensuring thread safety in parallel execution.
The createDriver() method is declared as abstract, indicating that it must be implemented by subclasses. This method is responsible for creating the RemoteWebDriver instance.
getDriver()is a static method that returns theRemoteWebDriverinstance stored in theThreadLocalvariable.setWebDriver(RemoteWebDriver driver_)is a static method used to set theRemoteWebDriverinstance in theThreadLocalvariable.
This code serves as a base class for managing the creation and retrieval of the RemoteWebDriver instance. By using ThreadLocal, it ensures that each thread has its own driver instance, which is essential for parallel test execution.
Subclasses of DriverManager can extend this class and provide the implementation for the createDriver() method based on the specific WebDriver implementation they want to use (e.g., ChromeDriver, FirefoxDriver). This allows for flexibility and easy switching between different WebDriver implementations.
Next We will discuss about Various DriverManager implementations.
for better understanding , please refer my previous post .
link : Create WebUi Action Wrapper class to write common methods (azharuddinkhan2586.blogspot.com)
Comments
Post a Comment