Web Automation using Selenium Webdriver

WebDriver is a web automation framework that allows you to execute your tests cases on different browsers like Google Chrome, Safari, Opera, Internet Explorer etc.

It allow you to use to different Programming Languages like Java, C#, Python, Ruby, Perl, etc.

In Selenium IDE We can't use Conditional, looping operation. It is possible in Selenium Webdriver. 

You get the actual control of browser(driver). It has very simple commands to use & very fast interaction with browser.

Let's Configure Selenium Webdriver first.

To Start with Selenium Webdriver, We need Eclipse IDE, Language Specific driver e.g. Java, C#, Ruby, Python, Javascript. Any Web browser should be installed on your machine. Browser other than Firefox needs its driver server. E.g. To Execute Selenium test case on Google Chrome you need Google Chrome driver. Let’s Setup for Webdriver.

Step 1: Download & install java on your system from http://www.oracle.com/technetwork/java/javase/downloads/index.html
Make sure that java version should be 1.7 or higher than it.

Step 2: Download Eclipse IDE for Java Developers from https://eclipse.org/downloads/ as per your System requirement.

Step 3: Download Selenium Java Client Java Driver from http://docs.seleniumhq.org/download/
& Save it to your working directory.

Step 4: Open Eclipse IDE & Set your workspace.


Step 5: Create New Java Project. Write Project Name & Select Execution environment as java se 1.7 or higher than it. Click on Next button.



Step 6:
 Click on Add External Jars Button.


Step 7: Select all jars & click on Open Button.


























Once you Import all jars click Finish button. You have done with Webdriver Setup.

Here are the actual steps for Setup.

Setup Selenium Webdriver:





Now We will write First Test script in Selenium Webdriver:

Define Interface Webdriver & Open Url: 

//Let’s Define Interface Webdriver for class FirefoxDriver
FirefoxDriver driver=new FirefoxDriver();

//Open Url
driver.get("http://newtours.demoaut.com/");

Locating Textbox & Link:

//Click On Register link
driver.findElement(By.linkText("REGISTER")).click();

//Enter First name
driver.findElement(By.name("firstName")).sendKeys("Gopal");

//Enter Last name

driver.findElement(By.name("lastName")).sendKeys("Mule");





Target Dropdown element using Select & Locate Button: 

//Select Dropdown Values
Select selcountry= new Select(driver.findElement(By.name("country")));
selcountry.selectByValue("92");

//Click On Submit Button
driver.findElement(By.name("register")).click();

2 comments: