SlideShare a Scribd company logo
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
Selenium Automation set up
with TestNG and Eclipse- A
Beginners Guide
Authors: Eevuri Sri Harsha, Ranjani Sivagnanam
Sri Harsha is working as an Associate Software Engineer (QA) for IBM Policy Atlas
team under ECM. Reach out to her at eeharsha@in.ibm.com
Ranjani, is working as a Staff Software Engineer (QA) for IBM Policy Atlas team
under ECM. Reach out to her at ranjani.sivagnanam@in.ibm.com
Abstract: This article is a guide for the beginners when they use Selenium, Testing
and Eclipse IDE for automation testing
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
1. Introduction
Selenium IDE/Web driver has becoming a very popular testing tool as it is an open source. This is a GUI
Automation tool. This is a beginner’s guide to install and use Selenium with Testing and Eclipse IDE. This
gives a step by step installation guide to Kick-start an Automation journey.
This document will describe one of the ways of setting up the environment automating Web
Applications. Described here will be a sample test script, object repository build up using XPath or CSS,
reporting configuration for the test run.
1.1 Install Firefox in Windows:
1. Visit the Firefox download page in any browser (e.g. Microsoft Internet Explorer). The page will
automatically recommend the best version(s) of Firefox for you.
2. Firefox Download Page - Windows-> Download 32-bit-Firefox Setup 3.6.0.exe
3. Click on the green download link to download the Firefox installer. Start the process by clicking
Run.
4. Install Firefox 3.6 by a double click on Firefox icon -> click on next buttons, install button, Launch
Firefox by click on finish button.
5. See the below screens to follow up.
Figure 1
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
Figure 2
1.2 Install DOM Inspector:
1. Open Firefox 3.6 and go to Tools -> Add ons.
2. In Search tab give DOM Inspector: click on install the latest version.
3. Go to Tools-> Add ons -> Search -> give Inspect this as search term ad click on install the latest
version.
4. See the below screens to follow up.
Figure 3
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
Figure 4
1.3 Install JDK 1.7:
1. Download Windows JDK 1.7 from
http://www.oracle.com/technetwork/java/javase/downloads/index.html
2. Install JDK 1.7
2. Selenium Introduction :
The Selenium-IDE (Integrated Development Environment) is the tool you use to develop your Selenium
test cases. It’s an easy-to-use Firefox plug-in and is generally the most efficient way to develop test
cases. It also contains a context menu that allows you to first select a UI element from the browser’s
currently displayed page and then select from a list of Selenium commands with parameters pre-defined
according to the context of the selected UI element. This is not only a time-saver, but also an excellent
way of learning Selenium script syntax.
2.1 Install Selenium IDE:
1. Open Firefox 3.6 and goto Tools -> ADD ONS.
2. In Search tab give Selenium IDE : click on install the latest version.
3. After install Selenium IDE -> Go to Tools-> Add Ons-> Extensions sub tab -> Selenium IDE .
4. Click on options in Selenium IDE.
5. Identify below tabs to work on Different platform Environments and to see default settings
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
Figure 5
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
Figure 6
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
2.2 Selenium Web Driver:
The biggest change in Selenium recently has been the inclusion of the Web Driver API. Driving a browser
natively as a user would either locally or on a remote machine using the Selenium Server it marks a leap
forward in terms of browser automation
Selenium 1.0 + Web Driver = Selenium 2.0
1. Web Driver is designed in a simpler and more concise programming interface along with
addressing some limitations in the Selenium-RC API.
2. It drives the browser much more effectively and over comes the limitations of Selenium 1.x
which affected our functional test coverage, like the file upload or download, pop-ups and
dialogs barrier.
3. To Support Web Driver we need to keep selenium standard 2.33 jar file in Project class path.
Install selenium-server-standalone-2.33.0.jar file to support Selenium Remote Web driver:
1. Download selenium-server-standalone-2.33.0.jar from web.
2. We need to keep selenium-server-standalone-2.33.0.jar in created Selenium Project Class path.
3. This jar file will support handling Remote browsers and web drivers, different browsers.
4. See the below screen for RC components.
Figure 7
2.3 Install DOM Inspector to inspect web elements using Xpath:
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
The web contains static and dynamic objects/elements. For static elements Ids are same at any time.
Ex: Button , Text box , Text Area ids .Using Inspect this element we can identify element id xpath.
1. While using Selenium IDE, sometimes the dynamic elements cannot be identified. These have to
be identified at run time.
2. Static elements are like button, text box, text area. For static elements Ids are same at any time.
3. But for Dynamic elements Ids will change at execution time.
4. DOM Inspector is useful to identify dynamic elements with common id at any time.
5. Here Xpath is creating id to identify dynamic element.
6. Example : Identify one checkbox id among multiple check boxes ids.
7. Check box id will change dynamically. That time Xpath using Dom inspector is useful to identify
the Id.
To explain how we use XPATH or CSS, here is an example:
On the home page of Google India search page, we see list of languages which can be used to convert
Google page into particular language.
The example is covering Google English to Google Hindi.
1. Open Firefox.
2. Open www.google.co.in page.
3. Open DOM Inspector from Tools-> Web developer -> DOM inspector -> click on cursor icon of
Dom inspector and click on any web element in Firefox to get id path.
4. See below screen for XPATH. Here its clicking on Hindi sub link and getting xpath.
Figure 8
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
1. XPATH generated is : //a[text()='Hindi']
2. Open Selenium IDE and give command as “highlight” or “Click”
3. Target is generated XPATH: //a[text()='Hindi']
4. Click on Find button in selenium IDE.
Results its highlights and click the "Hindi" Language.
See below screen.
Figure 9
2.3.1 Few points to note about XPATH:
An XPATH axis is a path through the node tree making use of particular relationship between nodes. We
use the "child::*" axis and the "attribute::*" axis all the time but mostly their short form: "*" and "@*".
The other axes are used far less often.
Follow below website to get good command on XPATH creation.
http://www.xmlplease.com/axis
CSS
Another way of locating the objects is by using CSS Selectors instead of XPATH:
Open the Selenium IDE > Options > Options> Locator Builders > Make sure CSS is present in the list
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
Figure 10
For this we can use DOM Inspector to get the elements, its attributes and its hierarchy
To locate a text field >
1. Open the www.google.co.in
2. Open the Selenium IDE
3. Record the Clicking on the Hindi link
4. Stop recording
5. Select the Target as css
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
Figure 11
Please refer the site http://www.w3schools.com/cssref/css_selectors.asp to learn about CSS
selectors
3.Install eclipse.exe:
1. Download Eclipse Standard 4.3.1 from web.
2. Install Eclipse by double click on eclipse.exe.
3. Give project location as Workspace.
4. See the screens to install eclipse
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
Figure 12
3.1 Install TestNG
1. Open the eclipse.exe
2. Goto Help > Install New Software
3. Give the url http://beust.com/eclipse in the Work with field
4. Click on Add
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
5. TestNG will be listed
6. Check the checkbox against TestNG
7. Click Next
Figure 13
8. Click Next until the License Agreement screen appears
9. Click “I agree” option
10. Installing Software pop up comes up
Figure 14
11. Once the installation is complete, open File> New> Other(or Ctrl + N) > Testing Class must be
listed in the window
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
Figure 16
3.2 Creating a Java project:
1. Goto to Workbench
2. Click on File > New > Java Project
Figure 17
3. Choose your JRE version, latest being JavaSE – 1.7
4. Click on Finish
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
Figure 18
5. Add the Selenium jar to the library ( File> Properties > Goto Libraries > Add External JARs .. >
Select the selenium-server-standalone-2.25.0.jar or the latest selenium jar
Figure 19
It should be added
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
Figure 20
)
6. Create a new Class MyFirstAutomationScript.java
Figure 21
7. Import Testing packages
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
a. Click on MyFirstAutomationScript.java
b. Click New
c. Click TestNG class
d. Click @BeforeTest
e. Finish
Figure 22
8. Add the @BeforeTest method
9. Add the @AfterTest method
10. Add the test you have to do in the @Test annotation
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import org.openqa.selenium.By;
import org.seleniumhq.*;
import com.thoughtworks.selenium.Selenium;
import com.beust.testng.*;
import static org.testng.Assert.*;
public class MyFirstAutomationScript{
@Test
public void firstTest() {
//Write the selenium code to test a particular functionality
}
@BeforeTest
public void beforeTest() {
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
//Write the setup steps like starting the Selenium server, bringing
the application url up
}
@AfterTest
public void afterTest() {
//Write the cleanup steps like logging out of the application,
stopping the Selenium server
}
}
11. Click on the java class and Select Run as > TestNG Test
12. As a beginner in Automation, the first steps are to give proper logging setup. In TESTNG, we
have Reporter class which has logging functions which can be used.
Reporter.log("PASS : <font color="green"><b>"+ "Test case has
passed"+"</b></font><br/>");
The below given code is an example of how java classes and functions can be linked to xml files
Java classes and Functions:
We should write java functions to connect xml file and run the web application.
Write java class for each web component of application .Each java class is one component.
Template consists of set of functions as well as abstract methods.
Write java functions for each and every element (buttons, textbox) action items functions of particular
component.
Sample java code:
//import packages
//import Templates;
public class Template1 extends BaseTemplate
{
public static Template t1;
public static int i=0;
public static void function1 (ArrayList<StepData> stepDatas) throws Exception
{
Click ("elementid");
System.out.println ("Google");
}
}
Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide
Each Java function should be called inside xml file, values passed inside xml file will be passed to java
function and execution will be done according to xml file steps.
XML file:
1. XML stands for EXtensible Markup Language
2. XML is a markup language much like HTML.
3. Here every test script is written in xml file format with steps having element value and ID of the
element.
4. Each XML file generation is used to run each test script.
Example:
<TestStep action="function name" type="template path">
<StepDatas>
<StepData value="elementid"></StepData>
<StepData value="elementvalue"></StepData>
</StepDatas>
</TestStep>
5. Each Test step is one single action in web application. Web page element id, values will be pass
as single individual steps .XML test script generation is main part in automation web application.
Conclusion:
This article provides the outline for setting up all the tools required to start automation using Selenium
with Java Eclipse IDE. Additional to this, knowledge of Core JAVA is required to test the functionalities.
This document in brief overview these points:
1. Setup all the required software
2. Get to know how to write basic classes and methods in Core JAVA
3. Using DOM Inspector, recognize the objects in web page
4. Run the tests as Testing Test
5. Reporting can be done by using the TestNG Reporter class.

More Related Content

What's hot (20)

Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentation
Sanjib Dhar
 
Test NG Framework Complete Walk Through
Test NG Framework Complete Walk ThroughTest NG Framework Complete Walk Through
Test NG Framework Complete Walk Through
Narendran Solai Sridharan
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
Denis Bazhin
 
TestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the warTestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the war
Oleksiy Rezchykov
 
Test ng tutorial
Test ng tutorialTest ng tutorial
Test ng tutorial
Srikrishna k
 
TestNG Session presented in PB
TestNG Session presented in PBTestNG Session presented in PB
TestNG Session presented in PB
Abhishek Yadav
 
TestNG
TestNGTestNG
TestNG
Prabhanshu Saraswat
 
TestNG Framework
TestNG Framework TestNG Framework
TestNG Framework
Levon Apreyan
 
testng
testngtestng
testng
harithakannan
 
Selenium TestNG
Selenium TestNGSelenium TestNG
Selenium TestNG
KadarkaraiSelvam
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
shaunthomas999
 
TestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit TestingTestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit Testing
Bethmi Gunasekara
 
Presentation
PresentationPresentation
Presentation
Igor Vlahek
 
TestNG Data Binding
TestNG Data BindingTestNG Data Binding
TestNG Data Binding
Matthias Rothe
 
Intro To Unit and integration Testing
Intro To Unit and integration TestingIntro To Unit and integration Testing
Intro To Unit and integration Testing
Paul Churchward
 
Test ng
Test ngTest ng
Test ng
Ramakrishna kapa
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NET
Baskar K
 
ikp321-04
ikp321-04ikp321-04
ikp321-04
Anung Ariwibowo
 
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Jacinto Limjap
 
Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)
Gopi Raghavendra
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentation
Sanjib Dhar
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
Denis Bazhin
 
TestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the warTestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the war
Oleksiy Rezchykov
 
TestNG Session presented in PB
TestNG Session presented in PBTestNG Session presented in PB
TestNG Session presented in PB
Abhishek Yadav
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
shaunthomas999
 
TestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit TestingTestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit Testing
Bethmi Gunasekara
 
Intro To Unit and integration Testing
Intro To Unit and integration TestingIntro To Unit and integration Testing
Intro To Unit and integration Testing
Paul Churchward
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NET
Baskar K
 
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Jacinto Limjap
 
Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)
Gopi Raghavendra
 

Similar to Selenium with testng and eclipse ide (20)

Automatedtestingwithselenium shubham jain
Automatedtestingwithselenium shubham jainAutomatedtestingwithselenium shubham jain
Automatedtestingwithselenium shubham jain
Prashant Gurav
 
Automated_Testing_Selenium
Automated_Testing_SeleniumAutomated_Testing_Selenium
Automated_Testing_Selenium
Jagdish Kaushal
 
Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch  Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch
Haitham Refaat
 
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Rashedul Islam
 
selenium training | selenium course | selenium video tutorial | selenium for ...
selenium training | selenium course | selenium video tutorial | selenium for ...selenium training | selenium course | selenium video tutorial | selenium for ...
selenium training | selenium course | selenium video tutorial | selenium for ...
Nancy Thomas
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
Selenium training
Selenium trainingSelenium training
Selenium training
Shivaraj R
 
Selenium IDE
Selenium IDESelenium IDE
Selenium IDE
b4usolution .
 
Selenium web driver
Selenium web driverSelenium web driver
Selenium web driver
Roman Savitskiy
 
Everything you need to know about the Selenium IDE: Tutorial
Everything you need to know about the Selenium IDE: TutorialEverything you need to know about the Selenium IDE: Tutorial
Everything you need to know about the Selenium IDE: Tutorial
pCloudy
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshers
Naga Mani
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
Aneesh Rangarajan
 
Selenium Online Training
Selenium Online Training Selenium Online Training
Selenium Online Training
Nagendra Kumar
 
Web testing with Selenium
Web testing with SeleniumWeb testing with Selenium
Web testing with Selenium
XBOSoft
 
Selenium Automation
Selenium AutomationSelenium Automation
Selenium Automation
Anuradha Malalasena
 
Selenium Basics by Quontra Solutions
Selenium Basics by Quontra SolutionsSelenium Basics by Quontra Solutions
Selenium Basics by Quontra Solutions
QUONTRASOLUTIONS
 
Learning selenium sample
Learning selenium sampleLearning selenium sample
Learning selenium sample
Minnu Jayaprakash
 
Interview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlotInterview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlot
Learning Slot
 
Automation With Selenium
Automation With SeleniumAutomation With Selenium
Automation With Selenium
kgrammer
 
Selenium course syllabus
Selenium course syllabusSelenium course syllabus
Selenium course syllabus
lakshmipriyaaka
 
Automatedtestingwithselenium shubham jain
Automatedtestingwithselenium shubham jainAutomatedtestingwithselenium shubham jain
Automatedtestingwithselenium shubham jain
Prashant Gurav
 
Automated_Testing_Selenium
Automated_Testing_SeleniumAutomated_Testing_Selenium
Automated_Testing_Selenium
Jagdish Kaushal
 
Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch  Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch
Haitham Refaat
 
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Rashedul Islam
 
selenium training | selenium course | selenium video tutorial | selenium for ...
selenium training | selenium course | selenium video tutorial | selenium for ...selenium training | selenium course | selenium video tutorial | selenium for ...
selenium training | selenium course | selenium video tutorial | selenium for ...
Nancy Thomas
 
Selenium training
Selenium trainingSelenium training
Selenium training
Shivaraj R
 
Everything you need to know about the Selenium IDE: Tutorial
Everything you need to know about the Selenium IDE: TutorialEverything you need to know about the Selenium IDE: Tutorial
Everything you need to know about the Selenium IDE: Tutorial
pCloudy
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshers
Naga Mani
 
Selenium Online Training
Selenium Online Training Selenium Online Training
Selenium Online Training
Nagendra Kumar
 
Web testing with Selenium
Web testing with SeleniumWeb testing with Selenium
Web testing with Selenium
XBOSoft
 
Selenium Basics by Quontra Solutions
Selenium Basics by Quontra SolutionsSelenium Basics by Quontra Solutions
Selenium Basics by Quontra Solutions
QUONTRASOLUTIONS
 
Interview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlotInterview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlot
Learning Slot
 
Automation With Selenium
Automation With SeleniumAutomation With Selenium
Automation With Selenium
kgrammer
 
Selenium course syllabus
Selenium course syllabusSelenium course syllabus
Selenium course syllabus
lakshmipriyaaka
 
Ad

Recently uploaded (20)

Risk Management in Software Projects: Identifying, Analyzing, and Controlling...
Risk Management in Software Projects: Identifying, Analyzing, and Controlling...Risk Management in Software Projects: Identifying, Analyzing, and Controlling...
Risk Management in Software Projects: Identifying, Analyzing, and Controlling...
gauravvmanchandaa200
 
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdf
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdfSecure and Simplify IT Management with ManageEngine Endpoint Central.pdf
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdf
Northwind Technologies
 
Optimising Claims Management with Claims Processing Systems
Optimising Claims Management with Claims Processing SystemsOptimising Claims Management with Claims Processing Systems
Optimising Claims Management with Claims Processing Systems
Insurance Tech Services
 
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptxHow AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
kalichargn70th171
 
The rise of e-commerce has redefined how retailers operate—and reconciliation...
The rise of e-commerce has redefined how retailers operate—and reconciliation...The rise of e-commerce has redefined how retailers operate—and reconciliation...
The rise of e-commerce has redefined how retailers operate—and reconciliation...
Prachi Desai
 
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdfHow to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
QuickBooks Training
 
AI Alternative - Discover the best AI tools and their alternatives
AI Alternative - Discover the best AI tools and their alternativesAI Alternative - Discover the best AI tools and their alternatives
AI Alternative - Discover the best AI tools and their alternatives
AI Alternative
 
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfol...
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfol...List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfol...
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfol...
Philip Schwarz
 
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdfBoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
Ortus Solutions, Corp
 
aswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjar
aswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjaraswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjar
aswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjar
muhammadalikhanalikh1
 
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdf
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdfHow a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdf
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdf
mary rojas
 
GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...
GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...
GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...
GirikHire
 
Custom Software Development: Types, Applications and Benefits.pdf
Custom Software Development: Types, Applications and Benefits.pdfCustom Software Development: Types, Applications and Benefits.pdf
Custom Software Development: Types, Applications and Benefits.pdf
Digital Aptech
 
UberEats clone app Development TechBuilder
UberEats clone app Development  TechBuilderUberEats clone app Development  TechBuilder
UberEats clone app Development TechBuilder
TechBuilder
 
Scalefusion Remote Access for Apple Devices
Scalefusion Remote Access for Apple DevicesScalefusion Remote Access for Apple Devices
Scalefusion Remote Access for Apple Devices
Scalefusion
 
How to purchase, license and subscribe to Microsoft Azure_PDF.pdf
How to purchase, license and subscribe to Microsoft Azure_PDF.pdfHow to purchase, license and subscribe to Microsoft Azure_PDF.pdf
How to purchase, license and subscribe to Microsoft Azure_PDF.pdf
victordsane
 
Shortcomings of EHS Software – And How to Overcome Them
Shortcomings of EHS Software – And How to Overcome ThemShortcomings of EHS Software – And How to Overcome Them
Shortcomings of EHS Software – And How to Overcome Them
TECH EHS Solution
 
Intranet Examples That Are Changing the Way We Work
Intranet Examples That Are Changing the Way We WorkIntranet Examples That Are Changing the Way We Work
Intranet Examples That Are Changing the Way We Work
BizPortals Solutions
 
War Story: Removing Offensive Language from Percona Toolkit
War Story: Removing Offensive Language from Percona ToolkitWar Story: Removing Offensive Language from Percona Toolkit
War Story: Removing Offensive Language from Percona Toolkit
Sveta Smirnova
 
Internship in South western railways on software
Internship in South western railways on softwareInternship in South western railways on software
Internship in South western railways on software
abhim5889
 
Risk Management in Software Projects: Identifying, Analyzing, and Controlling...
Risk Management in Software Projects: Identifying, Analyzing, and Controlling...Risk Management in Software Projects: Identifying, Analyzing, and Controlling...
Risk Management in Software Projects: Identifying, Analyzing, and Controlling...
gauravvmanchandaa200
 
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdf
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdfSecure and Simplify IT Management with ManageEngine Endpoint Central.pdf
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdf
Northwind Technologies
 
Optimising Claims Management with Claims Processing Systems
Optimising Claims Management with Claims Processing SystemsOptimising Claims Management with Claims Processing Systems
Optimising Claims Management with Claims Processing Systems
Insurance Tech Services
 
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptxHow AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
kalichargn70th171
 
The rise of e-commerce has redefined how retailers operate—and reconciliation...
The rise of e-commerce has redefined how retailers operate—and reconciliation...The rise of e-commerce has redefined how retailers operate—and reconciliation...
The rise of e-commerce has redefined how retailers operate—and reconciliation...
Prachi Desai
 
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdfHow to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
QuickBooks Training
 
AI Alternative - Discover the best AI tools and their alternatives
AI Alternative - Discover the best AI tools and their alternativesAI Alternative - Discover the best AI tools and their alternatives
AI Alternative - Discover the best AI tools and their alternatives
AI Alternative
 
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfol...
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfol...List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfol...
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfol...
Philip Schwarz
 
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdfBoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
Ortus Solutions, Corp
 
aswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjar
aswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjaraswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjar
aswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjar
muhammadalikhanalikh1
 
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdf
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdfHow a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdf
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdf
mary rojas
 
GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...
GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...
GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...
GirikHire
 
Custom Software Development: Types, Applications and Benefits.pdf
Custom Software Development: Types, Applications and Benefits.pdfCustom Software Development: Types, Applications and Benefits.pdf
Custom Software Development: Types, Applications and Benefits.pdf
Digital Aptech
 
UberEats clone app Development TechBuilder
UberEats clone app Development  TechBuilderUberEats clone app Development  TechBuilder
UberEats clone app Development TechBuilder
TechBuilder
 
Scalefusion Remote Access for Apple Devices
Scalefusion Remote Access for Apple DevicesScalefusion Remote Access for Apple Devices
Scalefusion Remote Access for Apple Devices
Scalefusion
 
How to purchase, license and subscribe to Microsoft Azure_PDF.pdf
How to purchase, license and subscribe to Microsoft Azure_PDF.pdfHow to purchase, license and subscribe to Microsoft Azure_PDF.pdf
How to purchase, license and subscribe to Microsoft Azure_PDF.pdf
victordsane
 
Shortcomings of EHS Software – And How to Overcome Them
Shortcomings of EHS Software – And How to Overcome ThemShortcomings of EHS Software – And How to Overcome Them
Shortcomings of EHS Software – And How to Overcome Them
TECH EHS Solution
 
Intranet Examples That Are Changing the Way We Work
Intranet Examples That Are Changing the Way We WorkIntranet Examples That Are Changing the Way We Work
Intranet Examples That Are Changing the Way We Work
BizPortals Solutions
 
War Story: Removing Offensive Language from Percona Toolkit
War Story: Removing Offensive Language from Percona ToolkitWar Story: Removing Offensive Language from Percona Toolkit
War Story: Removing Offensive Language from Percona Toolkit
Sveta Smirnova
 
Internship in South western railways on software
Internship in South western railways on softwareInternship in South western railways on software
Internship in South western railways on software
abhim5889
 
Ad

Selenium with testng and eclipse ide

  • 1. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide Selenium Automation set up with TestNG and Eclipse- A Beginners Guide Authors: Eevuri Sri Harsha, Ranjani Sivagnanam Sri Harsha is working as an Associate Software Engineer (QA) for IBM Policy Atlas team under ECM. Reach out to her at [email protected] Ranjani, is working as a Staff Software Engineer (QA) for IBM Policy Atlas team under ECM. Reach out to her at [email protected] Abstract: This article is a guide for the beginners when they use Selenium, Testing and Eclipse IDE for automation testing
  • 2. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide 1. Introduction Selenium IDE/Web driver has becoming a very popular testing tool as it is an open source. This is a GUI Automation tool. This is a beginner’s guide to install and use Selenium with Testing and Eclipse IDE. This gives a step by step installation guide to Kick-start an Automation journey. This document will describe one of the ways of setting up the environment automating Web Applications. Described here will be a sample test script, object repository build up using XPath or CSS, reporting configuration for the test run. 1.1 Install Firefox in Windows: 1. Visit the Firefox download page in any browser (e.g. Microsoft Internet Explorer). The page will automatically recommend the best version(s) of Firefox for you. 2. Firefox Download Page - Windows-> Download 32-bit-Firefox Setup 3.6.0.exe 3. Click on the green download link to download the Firefox installer. Start the process by clicking Run. 4. Install Firefox 3.6 by a double click on Firefox icon -> click on next buttons, install button, Launch Firefox by click on finish button. 5. See the below screens to follow up. Figure 1
  • 3. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide Figure 2 1.2 Install DOM Inspector: 1. Open Firefox 3.6 and go to Tools -> Add ons. 2. In Search tab give DOM Inspector: click on install the latest version. 3. Go to Tools-> Add ons -> Search -> give Inspect this as search term ad click on install the latest version. 4. See the below screens to follow up. Figure 3
  • 4. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide Figure 4 1.3 Install JDK 1.7: 1. Download Windows JDK 1.7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html 2. Install JDK 1.7 2. Selenium Introduction : The Selenium-IDE (Integrated Development Environment) is the tool you use to develop your Selenium test cases. It’s an easy-to-use Firefox plug-in and is generally the most efficient way to develop test cases. It also contains a context menu that allows you to first select a UI element from the browser’s currently displayed page and then select from a list of Selenium commands with parameters pre-defined according to the context of the selected UI element. This is not only a time-saver, but also an excellent way of learning Selenium script syntax. 2.1 Install Selenium IDE: 1. Open Firefox 3.6 and goto Tools -> ADD ONS. 2. In Search tab give Selenium IDE : click on install the latest version. 3. After install Selenium IDE -> Go to Tools-> Add Ons-> Extensions sub tab -> Selenium IDE . 4. Click on options in Selenium IDE. 5. Identify below tabs to work on Different platform Environments and to see default settings
  • 5. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide Figure 5
  • 6. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide Figure 6
  • 7. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide 2.2 Selenium Web Driver: The biggest change in Selenium recently has been the inclusion of the Web Driver API. Driving a browser natively as a user would either locally or on a remote machine using the Selenium Server it marks a leap forward in terms of browser automation Selenium 1.0 + Web Driver = Selenium 2.0 1. Web Driver is designed in a simpler and more concise programming interface along with addressing some limitations in the Selenium-RC API. 2. It drives the browser much more effectively and over comes the limitations of Selenium 1.x which affected our functional test coverage, like the file upload or download, pop-ups and dialogs barrier. 3. To Support Web Driver we need to keep selenium standard 2.33 jar file in Project class path. Install selenium-server-standalone-2.33.0.jar file to support Selenium Remote Web driver: 1. Download selenium-server-standalone-2.33.0.jar from web. 2. We need to keep selenium-server-standalone-2.33.0.jar in created Selenium Project Class path. 3. This jar file will support handling Remote browsers and web drivers, different browsers. 4. See the below screen for RC components. Figure 7 2.3 Install DOM Inspector to inspect web elements using Xpath:
  • 8. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide The web contains static and dynamic objects/elements. For static elements Ids are same at any time. Ex: Button , Text box , Text Area ids .Using Inspect this element we can identify element id xpath. 1. While using Selenium IDE, sometimes the dynamic elements cannot be identified. These have to be identified at run time. 2. Static elements are like button, text box, text area. For static elements Ids are same at any time. 3. But for Dynamic elements Ids will change at execution time. 4. DOM Inspector is useful to identify dynamic elements with common id at any time. 5. Here Xpath is creating id to identify dynamic element. 6. Example : Identify one checkbox id among multiple check boxes ids. 7. Check box id will change dynamically. That time Xpath using Dom inspector is useful to identify the Id. To explain how we use XPATH or CSS, here is an example: On the home page of Google India search page, we see list of languages which can be used to convert Google page into particular language. The example is covering Google English to Google Hindi. 1. Open Firefox. 2. Open www.google.co.in page. 3. Open DOM Inspector from Tools-> Web developer -> DOM inspector -> click on cursor icon of Dom inspector and click on any web element in Firefox to get id path. 4. See below screen for XPATH. Here its clicking on Hindi sub link and getting xpath. Figure 8
  • 9. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide 1. XPATH generated is : //a[text()='Hindi'] 2. Open Selenium IDE and give command as “highlight” or “Click” 3. Target is generated XPATH: //a[text()='Hindi'] 4. Click on Find button in selenium IDE. Results its highlights and click the "Hindi" Language. See below screen. Figure 9 2.3.1 Few points to note about XPATH: An XPATH axis is a path through the node tree making use of particular relationship between nodes. We use the "child::*" axis and the "attribute::*" axis all the time but mostly their short form: "*" and "@*". The other axes are used far less often. Follow below website to get good command on XPATH creation. http://www.xmlplease.com/axis CSS Another way of locating the objects is by using CSS Selectors instead of XPATH: Open the Selenium IDE > Options > Options> Locator Builders > Make sure CSS is present in the list
  • 10. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide Figure 10 For this we can use DOM Inspector to get the elements, its attributes and its hierarchy To locate a text field > 1. Open the www.google.co.in 2. Open the Selenium IDE 3. Record the Clicking on the Hindi link 4. Stop recording 5. Select the Target as css
  • 11. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide Figure 11 Please refer the site http://www.w3schools.com/cssref/css_selectors.asp to learn about CSS selectors 3.Install eclipse.exe: 1. Download Eclipse Standard 4.3.1 from web. 2. Install Eclipse by double click on eclipse.exe. 3. Give project location as Workspace. 4. See the screens to install eclipse
  • 12. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide Figure 12 3.1 Install TestNG 1. Open the eclipse.exe 2. Goto Help > Install New Software 3. Give the url http://beust.com/eclipse in the Work with field 4. Click on Add
  • 13. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide 5. TestNG will be listed 6. Check the checkbox against TestNG 7. Click Next Figure 13 8. Click Next until the License Agreement screen appears 9. Click “I agree” option 10. Installing Software pop up comes up Figure 14 11. Once the installation is complete, open File> New> Other(or Ctrl + N) > Testing Class must be listed in the window
  • 14. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide Figure 16 3.2 Creating a Java project: 1. Goto to Workbench 2. Click on File > New > Java Project Figure 17 3. Choose your JRE version, latest being JavaSE – 1.7 4. Click on Finish
  • 15. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide Figure 18 5. Add the Selenium jar to the library ( File> Properties > Goto Libraries > Add External JARs .. > Select the selenium-server-standalone-2.25.0.jar or the latest selenium jar Figure 19 It should be added
  • 16. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide Figure 20 ) 6. Create a new Class MyFirstAutomationScript.java Figure 21 7. Import Testing packages
  • 17. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide a. Click on MyFirstAutomationScript.java b. Click New c. Click TestNG class d. Click @BeforeTest e. Finish Figure 22 8. Add the @BeforeTest method 9. Add the @AfterTest method 10. Add the test you have to do in the @Test annotation import org.testng.annotations.Test; import org.testng.annotations.BeforeTest; import org.testng.annotations.AfterTest; import org.openqa.selenium.By; import org.seleniumhq.*; import com.thoughtworks.selenium.Selenium; import com.beust.testng.*; import static org.testng.Assert.*; public class MyFirstAutomationScript{ @Test public void firstTest() { //Write the selenium code to test a particular functionality } @BeforeTest public void beforeTest() {
  • 18. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide //Write the setup steps like starting the Selenium server, bringing the application url up } @AfterTest public void afterTest() { //Write the cleanup steps like logging out of the application, stopping the Selenium server } } 11. Click on the java class and Select Run as > TestNG Test 12. As a beginner in Automation, the first steps are to give proper logging setup. In TESTNG, we have Reporter class which has logging functions which can be used. Reporter.log("PASS : <font color="green"><b>"+ "Test case has passed"+"</b></font><br/>"); The below given code is an example of how java classes and functions can be linked to xml files Java classes and Functions: We should write java functions to connect xml file and run the web application. Write java class for each web component of application .Each java class is one component. Template consists of set of functions as well as abstract methods. Write java functions for each and every element (buttons, textbox) action items functions of particular component. Sample java code: //import packages //import Templates; public class Template1 extends BaseTemplate { public static Template t1; public static int i=0; public static void function1 (ArrayList<StepData> stepDatas) throws Exception { Click ("elementid"); System.out.println ("Google"); } }
  • 19. Selenium with TESTNG and eclipse IDE- Automation Beginner’s guide Each Java function should be called inside xml file, values passed inside xml file will be passed to java function and execution will be done according to xml file steps. XML file: 1. XML stands for EXtensible Markup Language 2. XML is a markup language much like HTML. 3. Here every test script is written in xml file format with steps having element value and ID of the element. 4. Each XML file generation is used to run each test script. Example: <TestStep action="function name" type="template path"> <StepDatas> <StepData value="elementid"></StepData> <StepData value="elementvalue"></StepData> </StepDatas> </TestStep> 5. Each Test step is one single action in web application. Web page element id, values will be pass as single individual steps .XML test script generation is main part in automation web application. Conclusion: This article provides the outline for setting up all the tools required to start automation using Selenium with Java Eclipse IDE. Additional to this, knowledge of Core JAVA is required to test the functionalities. This document in brief overview these points: 1. Setup all the required software 2. Get to know how to write basic classes and methods in Core JAVA 3. Using DOM Inspector, recognize the objects in web page 4. Run the tests as Testing Test 5. Reporting can be done by using the TestNG Reporter class.