How Selenium WebDriver Works

Selenium-WebDriver was developed to better support dynamic web pages where elements of a page may change without the page itself being reloaded. WebDriver’s goal is to supply a well-designed object-oriented API that provides improved support for modern advanced web-app testing problems.

Selenium webdriver was released as a part pf selenium 2.0 to overcome selenium 1.0 or selenium RC limitations like
– Issues working with pop-ups
– Dialogs
– Multiple browser
– File upload and download

It is an object oriented as compared to selenium 1.0 in terms of working with webelement, windows, dialogs by creating object.

It is designed in simpler and better way for modern web application and uses browser native command to drive the browser.

It support multiple browser, operating system and programming language

WebDriver works as an interface which used to drive / call the browser (Firefox, Chrome, IE etc) using each browsers native supports for automation.

WebDriver will run the browser directly.

Example -:
package Element;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class browser {

public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
driver.get(“https://www.google.co.in/”);
driver.findElement(By.id(“lst-ib”)).sendKeys(“WebDriver in Selenium”);
driver.close();
}

}

In result some elements works like -:
WebDriver driver = Create WebDriver instance
FirefoxDriver() = Implement Firefox browser
import org.openqa.selenium.WebDriver = Import WebDriver driver form other class for use
import org.openqa.selenium.firefox.FirefoxDriver = import Firefox driver from other class for use
WebDriver driver = new FirefoxDriver() = Open Firefox
driver.get(“https://www.google.co.in/”) = Open Google.co.in home page
driver.findElement(By.id(“lst-ib”)).sendKeys(“WebDriver in Selenium”) = Type in Google search box “WebDriver in Selenium”
driver.close() = Close the Firefox window

From the above code, will get results in the form of -:
– Firstly open the Google home page in Firefox browser
– Write WebDriver in Selenium in Google search engine
– Close the Firefox browser

Leave a Reply