Sunday 2 November 2014

Getting Started With Webdriver

Selenium:
Selenium is a web application testing automation tool which is used to automate your testcases.Its script can be written using programming languages such as Java, Python, C#, Groovy, Perl and Rubby.Selenium can be run on windows, Linux and MAC OS.

What is web driver?
Webdriver is an interface in selenium API.Using webdriver commands, you can open in any browser to run your testcases.As, all these classes [ChromeDriver, FirefoxDriver, InternetExplorerDriver, SafariDriver, HTMLUnitDriver, EventFiringDriver, RemoteWebDriver] implements webdriver interface, that means these classes will have the same functions as the webdriver interface.

Below are the commands used for FF, Chrome and IE -

For Firefox:
FirefoxDriver driver = new FirefoxDriver();

For Chrome:
As Firefox command,creating object of ChromeDriver & running, will throw you an
error as Chrome is a third part browser which is not developed by seleniumhq.
So, you need to download the Chrome extension zip file from this link -
http://docs.seleniumhq.org/download/

System.setProperty("webdriver.chrome.driver", "Chrome exe path\\chromedriver.exe");
ChromeDriver driver = new ChromeDriver();

For InternetExplorer:
For IE, you need to download the zip file from the given link- http://docs.seleniumhq.org/download/

System.setProperty("webdriver.ie.driver", "IE exe path\\IEDriverServer.exe");
InternetExplorerDriver driver = new InternetExplorerDriver();

Why webdriver is used?
  1. Commands are written with the help of webdriver by creating object for any browser specific driver and are sent to browser.
  2. It allows you to run the testcases in different browsers.
  3. It is faster as for its simpler architecture
How to download webdriver jars & configure in eclipse?
For configuring web driver jars, download jars from this link- http://docs.seleniumhq.org/download/

Here are the steps to configure web driver jar files in Eclipse:

1)Right click on Project

2)Select the Java Build path → Libraries tab

3)Click on Add External Jars button
 

4)Add all the Jar files (outside two jar files along with all the jar files inside the libs folder) which were downloaded
 

5)Click on OK button

No comments:

Post a Comment