Skip to main content

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 the RemoteWebDriver instance stored in the ThreadLocal variable.
  • setWebDriver(RemoteWebDriver driver_) is a static method used to set the RemoteWebDriver instance in the ThreadLocal variable.

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

Popular posts from this blog

  Step 1: Create an interface and declare some common unimplemented methods Step 2: Create UIAction class which implements this interface   Step 3: Create Base Page Step 4: Create Pages which extends this Base page Step5: Create Login Test and test this implementation Note : Here I have used Junit Testing framework for testing along with Selenium Java Binding used few oops features like inheritance , abstraction etc. What is DriverManager , DriverFactory  I will discuss in next post.  Soon I will be adding this code to github repo. @Author  Azharuddin Khan https://www.linkedin.com/in/azharuddin-k-27aa7a18b/