Selenium WebDriver

As we discussed earlier, Selenium WebDriver is powerful and key feature of the Selenium automation testing. The biggest advantage of this is WebDriver API. It is generally known as Selenium 2 which the enhancement of Selenium 1.

Unlike Selenium IDE, WebDriver is the most power tool for Automation Testing. In WebDriver,  you can design the Test Script in any programming language like Java, C#, Python, Ruby etc. Also, you can integrate with any browser like Chrome, Mozilla Firefox, IE, Safari.
 

WebDriver is designed with a simple and concise programming interface along with the limitations of the RC. So, WebDriver overcome the limitations of the RC.

If you want to create robust and browser-based regression test script then scale the test script across many environment, then Selenium WebDriver is the best option to choose.

Do you need to use Selenium Server?

It is also depending on you how you intend to use. If you want to execute the test script in your own local machine, then no need to use the Selenium Server.

Below are the reasons for which you need selenium server to execute the script.

  • If you want to integrate your test script with Selenium Grid, you need Selenium server to compatible with Grid.
  • If you want to connect to Remote machine having a different browser, then also you need Selenium Server.
  • To work with HtmlUnit for headless browser, You need to use Selenium Server.

Now we got the clear picture of the Selenium, Selenium Server and Selenium WebDriver.

What is WebDriver?

WebDriver is a framework. It drives its own web. When you are required to design the test case then WebDriver helps you to write automation test script.

In technical term, Webdriver is an Interface. Search Context which is the top level Interface, extended by WebDriver. This defines all common method like findElement(), findElements(), switchTo(), get() etc. But Remote WebDriver defines all those classes.

From the above figure we can understand that WebDriver extends the Search Context and Remote WebDriver implements WebDriver. So Webdriver is an Interface where as Remote WebDriver is a class. WebDriver contains method signature where as Remote webDriver contains the definitions of those methods.

Now you can ask that how to define WebDriver? You can define WebDriver as below.

WebDriver driver = new FirefoxDriver();

Here we have created the object for FirefoxDriver class by taking reference of WebDriver Interface. So that we can call WebDriver Interface implemented method. When we will execute this code in selenium, it will open the Firefox Browser with a new session. we can use get() method to open a URL which we will discuss in upcoming section.

Leave a Reply

Your email address will not be published. Required fields are marked *