SlideShare a Scribd company logo
Selenium with java
What is WebDriver?
• WebDriver is a web automation framework, allows you to
execute your tests against different browsers, not just
Firefox.
• It Supports almost all browser
• It uses programming languages:
• JAVA
• PHP
• Python
• PERL
• Many more..
Step 1 - Install Java on your computer (Latest JDK)
Go to http://ninite.com and choose the JDK.
Step 2 - Install Eclipse IDE
Go to https://ninite.com/
Step 3 - Download the Selenium Java Client Driver
http://docs.seleniumhq.org/download/
• Launch the "eclipse.exe" file inside the "eclipse" folder.
• When asked to select for a workspace, just accept the
default location.
• Create a new project through File > New > Java Project.
Name the project as "newproject".
• A new pop-up window will open enter details as follow
1. Project Name
2. Location to save project
3. Select an execution JRE
4. Select layout project option
5. Click on finish button
Configure Eclipse IDE with WebDriver
• In this step,
• Right-click on the newly created project and
• Select New > Package, and name that package as
"newpackage".
• A pop-up window will open to name the package,
Enter the name of the package
Click on finish button
• Create a new Java class under newpackage by right-clicking
on it and then selecting- New > Class, and then name it as
"MyClass". Your Eclipse IDE should look like the image
below.
Configure Eclipse IDE with WebDriver
• When you click on Class, a pop-up window will open, enter
details as
• Name of the class
• Click on Finish button
• Now selenium WebDriver's into Java Build Path
• In this step,
• Right-click on "newproject" and select Properties.
• On the Properties dialog, click on "Java Build Path".
• Click on the Libraries tab, and then
• Click on "Add External JARs.."
Configure Eclipse IDE with WebDriver
• package mypackage;
•
• import org.openqa.selenium.WebDriver;
• import org.openqa.selenium.firefox.FirefoxDriver;
•
• public class myclass {
•
• public static void main(String[] args) {
• // declaration and instantiation of objects/variables
• WebDriver driver = new FirefoxDriver();
• String baseUrl = "http://newtours.demoaut.com";
• String expectedTitle = "Welcome: Mercury Tours";
• String actualTitle = "";
•
• // launch Firefox and direct it to the Base URL
• driver.get(baseUrl)
First Webdriver code
• // get the actual value of the title
• actualTitle = driver.getTitle();
•
• /*
• * compare the actual title of the page witht the expected one and print
• * the result as "Passed" or "Failed"
• */
• if (actualTitle.contentEquals(expectedTitle)){
• System.out.println("Test Passed!");
• } else {
• System.out.println("Test Failed");
• }
•
• //close Firefox
• driver.close();
•
• // exit the program explicitly
• System.exit(0);
• }
•
• }
First Webriver code
• WebDriver provides these useful get commands:
• get()
• getTitle()
• getPageSource()
• getCurrentUrl()
• getText()
WebDriver get commands

More Related Content

PPT
selenium training | selenium course | selenium video tutorial | selenium for ...
Nancy Thomas
 
PPTX
Selenium Webdriver
Muhammad Bilal
 
PPTX
Automation - web testing with selenium
Tzirla Rozental
 
PPT
Automated Web Testing Using Selenium
Weifeng Zhang
 
PDF
Web application testing with Selenium
Kerry Buckley
 
PPS
Selenium Demo
ankitslide
 
PPTX
Introduction to selenium
Archana Krushnan
 
PDF
Selenium web driver
Shobika Ramasubbarayalu
 
selenium training | selenium course | selenium video tutorial | selenium for ...
Nancy Thomas
 
Selenium Webdriver
Muhammad Bilal
 
Automation - web testing with selenium
Tzirla Rozental
 
Automated Web Testing Using Selenium
Weifeng Zhang
 
Web application testing with Selenium
Kerry Buckley
 
Selenium Demo
ankitslide
 
Introduction to selenium
Archana Krushnan
 
Selenium web driver
Shobika Ramasubbarayalu
 

What's hot (20)

PPTX
How to Configure Selenium WebDriver (java)
Dasun Eranthika
 
PPTX
Selenium ppt
Aneesh Rangarajan
 
PPTX
Introduction to Selenium Web Driver
Return on Intelligence
 
DOCX
Selenium webdriver course content rakesh hansalia
Rakesh Hansalia
 
PPTX
Selenium
Satyam Pandey
 
PPTX
Get Started With Selenium 3 and Selenium 3 Grid
Daniel Herken
 
ODP
Mastering selenium for automated acceptance tests
Nick Belhomme
 
PPT
Selenium ppt
Naga Dinesh
 
PPT
Selenium
Kalyan ch
 
PDF
Selenium WebDriver with C#
srivinayak
 
DOCX
Selenium WebDriver FAQ's
Praveen Gorantla
 
PPT
Selenium By Pravin Mishra
Pravin Mishra
 
PDF
Selenium Ide Tutorial
metapix
 
PPT
Selenium ppt
Pavan Kumar
 
PPT
Selenium (1)
onlinemindq
 
PPTX
Selenium
Andrew Krug
 
PDF
Basics of Selenium IDE,Core, Remote Control
usha kannappan
 
PPTX
Selenium - Introduction
Sachin-QA
 
PPTX
Selenium web driver
Roman Savitskiy
 
PPTX
Selenium introduction
Pankaj Dubey
 
How to Configure Selenium WebDriver (java)
Dasun Eranthika
 
Selenium ppt
Aneesh Rangarajan
 
Introduction to Selenium Web Driver
Return on Intelligence
 
Selenium webdriver course content rakesh hansalia
Rakesh Hansalia
 
Selenium
Satyam Pandey
 
Get Started With Selenium 3 and Selenium 3 Grid
Daniel Herken
 
Mastering selenium for automated acceptance tests
Nick Belhomme
 
Selenium ppt
Naga Dinesh
 
Selenium
Kalyan ch
 
Selenium WebDriver with C#
srivinayak
 
Selenium WebDriver FAQ's
Praveen Gorantla
 
Selenium By Pravin Mishra
Pravin Mishra
 
Selenium Ide Tutorial
metapix
 
Selenium ppt
Pavan Kumar
 
Selenium (1)
onlinemindq
 
Selenium
Andrew Krug
 
Basics of Selenium IDE,Core, Remote Control
usha kannappan
 
Selenium - Introduction
Sachin-QA
 
Selenium web driver
Roman Savitskiy
 
Selenium introduction
Pankaj Dubey
 
Ad

Similar to Selenium with java (20)

PPTX
Selenium topic 4 - Selenium Web Driver Set Up
ITProfessional Academy
 
PPTX
Selenium Training in Chennai Demo Part-2
Thecreating Experts
 
DOCX
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Rashedul Islam
 
KEY
MozTW Jetpack Workshop: Taipei
littlebtc
 
PPTX
Servlet Demo (2).pptx
BalasundaramSr
 
PPTX
Getting up and running with selenium for automated Code palousa
Emma Armstrong
 
PPTX
Agile sites2
Michele Sciabarrà
 
PPT
Selenium Java for Beginners by Sujit Pathak
Software Testing Board
 
PDF
Beyond Domino Designer
Paul Withers
 
PDF
MozTW Jetpack Workshop: Taichung
littlebtc
 
PDF
WebObjects Developer Tools
WO Community
 
PDF
Web works hol
momoahmedabad
 
PPTX
Automated ui-testing
Slobodan Lohja
 
PPT
Selenium training in chennai
Thecreating Experts
 
PPT
Selenium Training in Chennai
Thecreating Experts
 
PPTX
DevCloud - Setup and Demo on Apache CloudStack
buildacloud
 
PDF
UKLUG 2012 - XPages, Beyond the basics
Ulrich Krause
 
PDF
Getting Started with Selenium
Dave Haeffner
 
PDF
Eclipse IDE, 2019.09, Java Development
Pei-Hsuan Hsieh
 
PPSX
Selenium WebDriver
Rajathi-QA
 
Selenium topic 4 - Selenium Web Driver Set Up
ITProfessional Academy
 
Selenium Training in Chennai Demo Part-2
Thecreating Experts
 
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Rashedul Islam
 
MozTW Jetpack Workshop: Taipei
littlebtc
 
Servlet Demo (2).pptx
BalasundaramSr
 
Getting up and running with selenium for automated Code palousa
Emma Armstrong
 
Agile sites2
Michele Sciabarrà
 
Selenium Java for Beginners by Sujit Pathak
Software Testing Board
 
Beyond Domino Designer
Paul Withers
 
MozTW Jetpack Workshop: Taichung
littlebtc
 
WebObjects Developer Tools
WO Community
 
Web works hol
momoahmedabad
 
Automated ui-testing
Slobodan Lohja
 
Selenium training in chennai
Thecreating Experts
 
Selenium Training in Chennai
Thecreating Experts
 
DevCloud - Setup and Demo on Apache CloudStack
buildacloud
 
UKLUG 2012 - XPages, Beyond the basics
Ulrich Krause
 
Getting Started with Selenium
Dave Haeffner
 
Eclipse IDE, 2019.09, Java Development
Pei-Hsuan Hsieh
 
Selenium WebDriver
Rajathi-QA
 
Ad

Recently uploaded (20)

PPTX
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PDF
Landforms and landscapes data surprise preview
jpinnuck
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PDF
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PDF
High Ground Student Revision Booklet Preview
jpinnuck
 
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
mansk2
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
PDF
Electricity-Magnetic-and-Heating-Effects 4th Chapter/8th-science-curiosity.pd...
Sandeep Swamy
 
PDF
Sunset Boulevard Student Revision Booklet
jpinnuck
 
PPTX
Introduction and Scope of Bichemistry.pptx
shantiyogi
 
Strengthening open access through collaboration: building connections with OP...
Jisc
 
Landforms and landscapes data surprise preview
jpinnuck
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
High Ground Student Revision Booklet Preview
jpinnuck
 
Week 4 Term 3 Study Techniques revisited.pptx
mansk2
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
Electricity-Magnetic-and-Heating-Effects 4th Chapter/8th-science-curiosity.pd...
Sandeep Swamy
 
Sunset Boulevard Student Revision Booklet
jpinnuck
 
Introduction and Scope of Bichemistry.pptx
shantiyogi
 

Selenium with java

  • 2. What is WebDriver? • WebDriver is a web automation framework, allows you to execute your tests against different browsers, not just Firefox. • It Supports almost all browser • It uses programming languages: • JAVA • PHP • Python • PERL • Many more..
  • 3. Step 1 - Install Java on your computer (Latest JDK) Go to http://ninite.com and choose the JDK. Step 2 - Install Eclipse IDE Go to https://ninite.com/ Step 3 - Download the Selenium Java Client Driver http://docs.seleniumhq.org/download/
  • 4. • Launch the "eclipse.exe" file inside the "eclipse" folder. • When asked to select for a workspace, just accept the default location. • Create a new project through File > New > Java Project. Name the project as "newproject". • A new pop-up window will open enter details as follow 1. Project Name 2. Location to save project 3. Select an execution JRE 4. Select layout project option 5. Click on finish button Configure Eclipse IDE with WebDriver
  • 5. • In this step, • Right-click on the newly created project and • Select New > Package, and name that package as "newpackage". • A pop-up window will open to name the package, Enter the name of the package Click on finish button • Create a new Java class under newpackage by right-clicking on it and then selecting- New > Class, and then name it as "MyClass". Your Eclipse IDE should look like the image below. Configure Eclipse IDE with WebDriver
  • 6. • When you click on Class, a pop-up window will open, enter details as • Name of the class • Click on Finish button • Now selenium WebDriver's into Java Build Path • In this step, • Right-click on "newproject" and select Properties. • On the Properties dialog, click on "Java Build Path". • Click on the Libraries tab, and then • Click on "Add External JARs.." Configure Eclipse IDE with WebDriver
  • 7. • package mypackage; • • import org.openqa.selenium.WebDriver; • import org.openqa.selenium.firefox.FirefoxDriver; • • public class myclass { • • public static void main(String[] args) { • // declaration and instantiation of objects/variables • WebDriver driver = new FirefoxDriver(); • String baseUrl = "http://newtours.demoaut.com"; • String expectedTitle = "Welcome: Mercury Tours"; • String actualTitle = ""; • • // launch Firefox and direct it to the Base URL • driver.get(baseUrl) First Webdriver code
  • 8. • // get the actual value of the title • actualTitle = driver.getTitle(); • • /* • * compare the actual title of the page witht the expected one and print • * the result as "Passed" or "Failed" • */ • if (actualTitle.contentEquals(expectedTitle)){ • System.out.println("Test Passed!"); • } else { • System.out.println("Test Failed"); • } • • //close Firefox • driver.close(); • • // exit the program explicitly • System.exit(0); • } • • } First Webriver code
  • 9. • WebDriver provides these useful get commands: • get() • getTitle() • getPageSource() • getCurrentUrl() • getText() WebDriver get commands