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 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, Driver

    <br>package com.mahesh.selenium.Main;import;  <p>import org.openqa.selenium.WebDriver;<br>import;</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("", file.getAbsolutePath());<br>WebDriver driver = new InternetExplorerDriver();</p> <p>driver.get("");<br>}<br>}<br>

    IE ResultHappy Learning!!!


2 responses

  1. I’ve recently had a play with Selenium, first in Java and then in python.

    Having now done both, if someone were to ask me, I would suggest using
    ipython as the easiest. least painful path to discovering selenium.

    $ ipython
    from selenium import webdriver

    d = webdriver. # you can type a and it would show you all the possible functions.

    # and you can see the results immediately.

    1. Thanks, But i don’t have knowledge in python, Will try to learn soon and post the same.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: