Selenium WebDriver – Architecture

In the last article we covered Selenium Configuration, in this article we’ll cover architecture of Selenium WebDriver.

An interface named WebDriver, which represents an idealized web browser, is the main interface used for testing. Classes like AndroidDriver, AndroidWebDriver, ChromeDriver, EventFiringWebDriver, FirefoxDriver, HtmlUnitDriver, InternetExplorerDriver, IPhoneDriver, IPhoneSimulatorDriver, RemoteWebDriver, SafariDriver etc; implements WebDriver interface.

Depending upon the browser which we want to use for automation, we can create objects as follows.

Similarly you can create objects of Chrome, Safari, Android depending upon our need. After creating object of WebDriver interface, we can call all the methods available inside it to create powerful automation suites. Following are few of the main methods present inside WebDriver interface whose actual implementation is done inside the classes which implements it.

1. get(java.lang.String url): Load a new web page in the current browser window.

2. getTitle(): The title of the current page is returned as a string.

3. getPageSource(): Get the source of the last loaded page.

4. findElement(By by): Find the first WebElement using given method. Argument ‘By’ is an inbuilt class, which is used to locate elements based on id, name, htmltag, xpath etc.This method returns WebElement object, using which we can perform different operations like click, type, select etc by calling appropriate methods of WebElement object.

5. close(): Close the current window, quitting the browser if it’s the last window currently open.

Selenium WebDriver API consists of lots of other inbuilt classes as well as interfaces, which will help you to create more powerful and robust automation scripts.  Selenium documentation is known as ‘javadoc’, which can be accessed using this url

facebook comments:

Leave a Comment

Previous post:

Next post: