SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
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

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
 

Similar to Selenium with java (20)

PPTX
Selenium Training in Chennai Demo Part-2
Thecreating Experts
 
DOCX
Selenium webdriver Setup | Selenium Webdriver with Java and Eclipse Setup
ComputerTrainingsOnline
 
PPTX
Step by step - Selenium 3 web-driver - From Scratch
Haitham Refaat
 
PPTX
Selenium web driver_2.0_presentation
sayhi2sudarshan
 
PPTX
Session 05 - Introduction to WebDriver - Part 02
SiddharthSelenium
 
PDF
Selenium Introduction by Sandeep Sharda
Er. Sndp Srda
 
PDF
Introduction to Selenium and WebDriver
TechWell
 
PDF
Setup of project in web driver
Raghav Arora
 
PPTX
Selenium webcrawler
Rabia Khalid
 
PPSX
Selenium WebDriver
ANKUR-BA
 
PPTX
Selenium WebDriver
Sachin-QA
 
DOCX
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Rashedul Islam
 
PDF
Web driver selenium simplified
Vikas Singh
 
PPTX
Automated software testing using Selenium WebDriver
Ilir Kosumi
 
PDF
Selenium Full Material( apprendre Selenium).pdf
Sdiri Ahmed
 
PDF
Selenium Clinic Eurostar 2012 WebDriver Tutorial
Alan Richardson
 
PPTX
Automation With Selenium
kgrammer
 
PPTX
Selenium Automation
Anuradha Malalasena
 
ODP
Basic testing with selenium
Søren Lund
 
Selenium Training in Chennai Demo Part-2
Thecreating Experts
 
Selenium webdriver Setup | Selenium Webdriver with Java and Eclipse Setup
ComputerTrainingsOnline
 
Step by step - Selenium 3 web-driver - From Scratch
Haitham Refaat
 
Selenium web driver_2.0_presentation
sayhi2sudarshan
 
Session 05 - Introduction to WebDriver - Part 02
SiddharthSelenium
 
Selenium Introduction by Sandeep Sharda
Er. Sndp Srda
 
Introduction to Selenium and WebDriver
TechWell
 
Setup of project in web driver
Raghav Arora
 
Selenium webcrawler
Rabia Khalid
 
Selenium WebDriver
ANKUR-BA
 
Selenium WebDriver
Sachin-QA
 
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Rashedul Islam
 
Web driver selenium simplified
Vikas Singh
 
Automated software testing using Selenium WebDriver
Ilir Kosumi
 
Selenium Full Material( apprendre Selenium).pdf
Sdiri Ahmed
 
Selenium Clinic Eurostar 2012 WebDriver Tutorial
Alan Richardson
 
Automation With Selenium
kgrammer
 
Selenium Automation
Anuradha Malalasena
 
Basic testing with selenium
Søren Lund
 
Ad

Recently uploaded (20)

PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
Introduction to Indian Writing in English
Trushali Dodiya
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
infertility, types,causes, impact, and management
Ritu480198
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Difference between write and update in odoo 18
Celine George
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
Ad

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