Tag Archives: WebDriver

Selenium Web Driver [Java] Introduction

What is Selenium?

Selenium is an automate testing framework for web applications. Selenium is composed of multiple software tools. Each has a specific role. Here let’s see about selenium web driver.

Selenium Web Driver

Selenium Web Driver accepts commands and sends them to a browser. This is implemented through a browser-specific browser driver, which sends commands to a browser, and retrieves results. Let’s see how to set up and do a simple automate test using java language.


Project Step-up

  1. Create a java project in Eclipse like below, File->New->Java ProjectCreating Java Project
  2. Then create a Class named SeleniumMain (As your wish) like below,Create Class
  3. Now add the Selenium jar to build path, which is downloaded before.

    Adding Jars into built path

  4. Now you could start write the code for testing the Application, Here let’s see how to open a flipkart website in Mozila firefox browser,Firefox Driver
  5. While running the SeleniumMain.java class, You would get the output as below,Firefox O/P
  6. If u want to use Internet explorer, the you should load the IEDriverServer.exe, which available in the below path,http://code.google.com/p/selenium/downloads/listIE Driver

    <br>package com.mahesh.selenium.Main;import java.io.File;  <p>import org.openqa.selenium.WebDriver;<br>import org.openqa.selenium.ie.InternetExplorerDriver;</p> <p>public class SeleniumMain {</p> <p>/**<br>* @param args<br>*/<br>public static void main(String[] args) {</p> <p>// Firfox driver.<br>//WebDriver driver = new FirefoxDriver();</p> <p>//IE Driver<br>File file = new File("C:/Jars/IEDriverServer.exe");<br>System.setProperty("webdriver.ie.driver", file.getAbsolutePath());<br>WebDriver driver = new InternetExplorerDriver();</p> <p>driver.get("http://www.flipkart.com");<br>}<br>}<br>

    IE ResultHappy Learning!!!