You are on page 1of 16

Learning Selenium

in 6 Easy Steps
A CYGNET INFOTECH E -BOOK

E-book: Learning Selenium Webdriver in 6 Easy Steps

Today, when web applications are developed for every


segment of industry and for every size of business, it has
also become very important to check its efficiency before
launching it on the board. Though the effectiveness of
testing applications varies from a company to company, it
is accepted as an essential part of the process.

E-book: Learning Selenium Webdriver in 6 Easy Steps

When testing is such an important task for an organization, Selenium


can indeed be called a blessing. Selenium, a widely used open source
web application test automation tool can be very useful to the group
of people who work on manual testing. It is becoming the first choice
of testers for testing GUI as well as the functionalities of the web
applications.

E-book: Learning Selenium Webdriver in 6 Easy Steps

Selenium IDE
Selenium is a package containing
various test components which
consists of the following four major
tools.
Each one of them has a specific role
in aiding the development of test
automation for a Web application.

A Firefox extension to record test cases and suites

Selenium Grid

Selenium RC

Runs multiple instances


of Selenium RC at once

Used to run tests on


different browsers and
systems

Selenium WebDriver
A well-designed object-oriented API that provides
improved support for modern advanced web-app
testing problems.

E-book: Learning Selenium in 6 Easy Steps

6 Easy Steps for


Learning Selenium
1 2 3 4 5 6

E-book: Learning Selenium Webdriver in 6 Easy Steps

1 2 3 4 5 6
You need a framework to work with Selenium before going further.
Write some simple coding to run your automation script across all
browsers. Though there are many frameworks available in the market,
we would consider Eclipse here which is again an open source. Eclipse
is also well known tool which is behave same like STS. And there will be
no change in configuration area if you are using Eclipse.
Download Eclipse

E-book: Learning Selenium Webdriver in 6 Easy Steps

1 2 3 4 5 6
Now, it is the time to select a language to
go ahead. We would prefer Java and thus,
give you guidelines accordingly.

First Download Selenium Libraries


For Selenium Webdriver you should get link
on location displayed in image.

E-book: Learning Selenium Webdriver in 6 Easy Steps

1 2 3 4 5 6
The actual work will start now.
Open Eclipse tool.
1.
2.
3.
4.
5.
6.
7.

Create one Java Project from the path


Enter project name and select location to save the
project
Click Next button once it enable.
Click Libraries tab.
Click Add External Jars button.
Select the Client Driver Java Jar file from the computer
location you just download.
Click Finish button once you done.

E-book: Learning Selenium Webdriver in 6 Easy Steps

1 2 3 4 5 6
Another way to add jar file is given below.
1.
2.
3.
4.

Create java Project just by entering name


Select location
Click Finish button.
Once project is created, right click on project name.

Once you done with above steps


you can start writing automation
scripts. Added jar file will be
displayed under Referenced
Libraries.

E-book: Learning Selenium Webdriver in 6 Easy Steps

1 2 3 4 5 6
Scripting can be written in Class file hence you need to create class file under
Java Project. Class file can be created from the path
.
If you are scared to write test cases in class, then Selenium IDE is there to help.
It will create class code for you for that you just need to understand IDE and
record the actions for which automation script is require.
Selenium IDE This is a Firefox Add-on (download it here).
Selenium IDE and install.

Download

IDE supports only Firefox hence we are using Selenium RC to run all recorded
scripts on different browsers. You can export recorded steps into selected
language format.

E-book: Learning Selenium Webdriver in 6 Easy Steps

1 2 3 4 5 6
Base URL: http://www.google.co.in
Command

Target

open

click

id=gbqfq

type

id=gbqfq

click

id=gbqfq

Value

Testing

E-book: Learning Selenium Webdriver in 6 Easy Steps

1 2 3 4 5 6
Now its time to run test case. Run is possible in many ways. One of the easiest ways is JUnit.
JUnit is used to run code internally which is mostly used by developer. You can use it like this:
Right click on Class file
Select Run As JUnit Test
There is one more tool available
which is used for report
creation and mostly used by
Testers named as TestNG.

E-book: Learning Selenium Webdriver in 6 Easy Steps

1 2 3 4 5 6
TestNG can be used to create selenium report in some good format for all created test
cases. For that you need to configure it in your project. Configuration is done by
adding a jar file for TestNG into your project and installing it in Framework like Eclipse
or STS.
Download TestNG jar file from: http://beust.com/eclipse
To run code using TestNG it should be installed in your framework. To install it follow below steps.
1. Go to HelpInstall New Software..
2. Click Add button
3. Enter name as TestNG and location as http://beust.com/eclipse.
4. Click OK button.
5. Check TestNG checkbox and click Next button.
6. Finish the process.
7. Restart the STS or Eclipse to take effect.

E-book: Learning Selenium Webdriver in 6 Easy Steps

1 2 3 4 5 6
The problem you will face is the format of code that you write for selenium script. TestNG
uses its own coding standard to interact with selenium or any other language. Format is
simple to understand so we will also use the same for some example.

Keep in mind that while you are running


script with TestNG, your selenium should
start before. TestNG provides facility to run
all test cases at same time. For that you need
to create one XML file. XML file will look like

E-book: Learning Selenium Webdriver in 6 Easy Steps

1 2 3 4 5 6
Steps to create XML file.
1. Right click on project.
2. Go to TestNGConvert to TestNG
3. Verify that testng.xml file created under your project.
4. Open file, it will look like above image.

Now, you can run your script(s) using TestNG.


1.
2.
3.
4.

Right click on testng.xml file


Go to Run asTestNG Suite
Wait till test case run.
Your will get good report format which can also be
open in browser.

Refer this link to get more understanding of selenium with given live scenario.

E-book: Learning Selenium Webdriver in 6 Easy Steps

In this e-book, we have tried to


explain Selenium WebDriver and
configuring Eclipse with Selenium
WebDriver. We hope this will be
quite helpful for you to
understand the process.
Phone:
India +91-79-30087900
USA: +1-201-600-9012
UK: +44-20-8099-1653
Email: inquiry@cygnet-infotech.com
Website: http://cygnet-infotech.com