SlideShare a Scribd company logo
14
Most read
19
Most read
20
Most read
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Topics to be covered…
01 Introduction to Xpath
02 XML Document
03 Benefits of Xpath
04 Syntax & Terminology
05 Types of Xpath
06 Xpath Functions
Introduction to
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Introduction To Xpath
XPath can be also defined as XML path
It consists of a path expression along with some conditions
Xpath is a language to query XML documents
Important strategy to locate elements in Selenium
XML Document
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
XML Document
<bookstore>
<book category= “cooking”>
<title lang=“en”>Everyday Chinese</title>
<author>K.S.Bose</author>
<book>
<book category= “children”>
<title lang=“en”>Harry Potter</title>
<author>J.K. Rowling</author>
<book>
bookstore
book (category: cooking)
author ( K.S
Bose)
author (J.K.
Rowling)
title (Everyday
Chinese)
book (category: children)
title (Harry
Potter)
XML Tree
bookstore
book (category: cooking)
author ( K.S
Bose)
author (J.K.
Rowling)
title (Everyday
Chinese)
book (category: children)
title (Harry
Potter)
XML Tree
Xpath = /bookstore/book[@category=‘children’]/author
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Benefits of Xpath
Queries are compact
Queries are easily parsed
Queries are easy to read & type
Queries do not return repeated nodes
Syntax is simple for simple and common cases
You can uniquely identify any node in XML Document
1
2
3
4
5
6
Syntax &
Terminology of
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Syntax and Terminology
Xpath=/tagname[@Attribute=‘Value’]
Select current node Select attributes Value of an attribute
Attribute Name
Tagname like input,
div, img etc
Types of
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Types of Xpath
Relative Xpath
Absolute Xpath
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Types of Xpath
Relative Xpath
Absolute Xpath It is the direct way to find the element, but the disadvantage of the
absolute XPath is that if there are any changes made in the path of the
element then that XPath gets failed.
Ex: /html/body/div[1]/section/div[1]/div
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Types of Xpath
Relative Xpath
Absolute Xpath For, Relative Xpath the path starts from the middle of the HTML DOM
structure. It starts with the double forward slash (//), which means it can
search the element anywhere at the webpage
Ex: //input[@id=‘ap_email’]
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selenium Training | Edureka
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
<bookstore>
<book category= “cooking”>
<title lang=“en”>Everyday Chinese</title>
<author>K.S.Bose</author>
<book>
<book category= “children”>
<title lang=“en”>Harry Potter</title>
<author>J.K. Rowling</author>
<book>
Xpath Functions
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Xpath Functions
text()
starts-with()
contains( )
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Xpath Functions
text()
starts-with()
contains( )
contains() is a method used in XPath expression. It is used when the
value of any attribute changes dynamically, for example, login
information.
Xpath=//*[contains(@type,'sub')]
Syntax:
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Xpath Functions
text()
contains( )
starts-with()
starts-with function finds the element whose attribute value
changes on refresh or any operation on the webpage.
Xpath=//label[starts-with(@id,’message')]
Syntax:
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Xpath Functions
starts-with()
contains( )
text()
In this expression, with text function, we find the element with exact text
match as shown below. In our case, we find the element with text
"UserID".
Syntax:
Xpath=//td[text()=’UserID’]
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selenium Training | Edureka

More Related Content

PDF
Selenium Interview Questions and Answers For Freshers And Experienced | Edureka
Edureka!
 
PDF
Java Collection Interview Questions [Updated]
SoniaMathias2
 
PPTX
Selenium-Locators
Mithilesh Singh
 
PPT
Java Basics for selenium
apoorvams
 
PDF
Selenium cheat sheet
Sri Priya P Kulkarni
 
PDF
Java 8 Stream API. A different way to process collections.
David Gómez García
 
PPTX
Selenium WebDriver training
Vijay Krishnan Ramaswamy
 
PDF
Manual Testing Interview Questions | Edureka
Edureka!
 
Selenium Interview Questions and Answers For Freshers And Experienced | Edureka
Edureka!
 
Java Collection Interview Questions [Updated]
SoniaMathias2
 
Selenium-Locators
Mithilesh Singh
 
Java Basics for selenium
apoorvams
 
Selenium cheat sheet
Sri Priya P Kulkarni
 
Java 8 Stream API. A different way to process collections.
David Gómez García
 
Selenium WebDriver training
Vijay Krishnan Ramaswamy
 
Manual Testing Interview Questions | Edureka
Edureka!
 

What's hot (20)

PPTX
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Pankaj Dubey
 
PDF
Selenium IDE LOCATORS
Mindfire Solutions
 
PDF
Selenium Page Object Model Using Page Factory | Selenium Tutorial For Beginne...
Edureka!
 
PDF
Selenium Maven With Eclipse | Edureka
Edureka!
 
PPTX
Modern JS with ES6
Kevin Langley Jr.
 
PDF
Spring Boot
Jaran Flaath
 
PDF
JPA and Hibernate
elliando dias
 
PPTX
TestNG Session presented in Xebia XKE
Abhishek Yadav
 
PDF
Selenium Automation Testing Interview Questions And Answers
Ajit Jadhav
 
PPTX
Setting up Page Object Model in Automation Framework
valuebound
 
PPTX
Selenium Locators
Satyam Pandey
 
PDF
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
Edureka!
 
PPTX
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
PPTX
JS Event Loop
Saai Vignesh P
 
PPT
jQuery
Mostafa Bayomi
 
PPT
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
PPTX
Automation - web testing with selenium
Tzirla Rozental
 
PDF
Spring boot jpa
Hamid Ghorbani
 
PPTX
Express js
Manav Prasad
 
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Pankaj Dubey
 
Selenium IDE LOCATORS
Mindfire Solutions
 
Selenium Page Object Model Using Page Factory | Selenium Tutorial For Beginne...
Edureka!
 
Selenium Maven With Eclipse | Edureka
Edureka!
 
Modern JS with ES6
Kevin Langley Jr.
 
Spring Boot
Jaran Flaath
 
JPA and Hibernate
elliando dias
 
TestNG Session presented in Xebia XKE
Abhishek Yadav
 
Selenium Automation Testing Interview Questions And Answers
Ajit Jadhav
 
Setting up Page Object Model in Automation Framework
valuebound
 
Selenium Locators
Satyam Pandey
 
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
Edureka!
 
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
JS Event Loop
Saai Vignesh P
 
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
Automation - web testing with selenium
Tzirla Rozental
 
Spring boot jpa
Hamid Ghorbani
 
Express js
Manav Prasad
 
Ad

Similar to Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selenium Training | Edureka (20)

PDF
Querring xml with xpath
Malintha Adikari
 
PDF
Xpath tutorial
Ashoka Vanjare
 
PPTX
xpaths.pptx
KundetiLeena1
 
PPTX
X path
Sagar Guhe
 
PPTX
X path
Sagar Guhe
 
PPT
03 x files
Baskarkncet
 
PDF
Using XPath in Selenium - All you need to know.pdf
flufftailshop
 
PPTX
Extracting data from xml
Kumar
 
PDF
A brief overview of XPath - Topic in XML - Web Technologies
SadhuRamakrishnanBal
 
PDF
Xpath.pdf
BalasundaramSr
 
PDF
Introduction to XPath
torp42
 
PPTX
Xpath & Xquery in XML documents for retreving data
aiswaryasathwik
 
PDF
Xpath1
Dr.Saranya K.G
 
PPT
Xpath presentation
Alfonso Gabriel López Ceballos
 
PDF
Querying XML: XPath and XQuery
Katrien Verbert
 
PPTX
Structured Strategy: How to Supercharge Your Content Analysis with XML and XPath
Josh Anderson
 
PPT
Xpath
Manav Prasad
 
PDF
Using XPath in Selenium_ All you need to know.pdf
RobertMartin69776
 
PPTX
XPath
Raji Ghawi
 
Querring xml with xpath
Malintha Adikari
 
Xpath tutorial
Ashoka Vanjare
 
xpaths.pptx
KundetiLeena1
 
X path
Sagar Guhe
 
X path
Sagar Guhe
 
03 x files
Baskarkncet
 
Using XPath in Selenium - All you need to know.pdf
flufftailshop
 
Extracting data from xml
Kumar
 
A brief overview of XPath - Topic in XML - Web Technologies
SadhuRamakrishnanBal
 
Xpath.pdf
BalasundaramSr
 
Introduction to XPath
torp42
 
Xpath & Xquery in XML documents for retreving data
aiswaryasathwik
 
Querying XML: XPath and XQuery
Katrien Verbert
 
Structured Strategy: How to Supercharge Your Content Analysis with XML and XPath
Josh Anderson
 
Using XPath in Selenium_ All you need to know.pdf
RobertMartin69776
 
XPath
Raji Ghawi
 
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
PDF
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
PDF
Tableau Tutorial for Data Science | Edureka
Edureka!
 
PDF
Python Programming Tutorial | Edureka
Edureka!
 
PDF
Top 5 PMP Certifications | Edureka
Edureka!
 
PDF
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
PDF
Linux Mint Tutorial | Edureka
Edureka!
 
PDF
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
PDF
Importance of Digital Marketing | Edureka
Edureka!
 
PDF
RPA in 2020 | Edureka
Edureka!
 
PDF
Email Notifications in Jenkins | Edureka
Edureka!
 
PDF
EA Algorithm in Machine Learning | Edureka
Edureka!
 
PDF
Cognitive AI Tutorial | Edureka
Edureka!
 
PDF
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
PDF
Blue Prism Top Interview Questions | Edureka
Edureka!
 
PDF
Big Data on AWS Tutorial | Edureka
Edureka!
 
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
PDF
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
PDF
Introduction to DevOps | Edureka
Edureka!
 
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Edureka!
 

Recently uploaded (20)

PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
PDF
Doc9.....................................
SofiaCollazos
 
PPT
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PPTX
C Programming Basics concept krnppt.pptx
Karan Prajapat
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PDF
Google’s NotebookLM Unveils Video Overviews
SOFTTECHHUB
 
This slide provides an overview Technology
mineshkharadi333
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
Doc9.....................................
SofiaCollazos
 
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
C Programming Basics concept krnppt.pptx
Karan Prajapat
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Software Development Company | KodekX
KodekX
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
Google’s NotebookLM Unveils Video Overviews
SOFTTECHHUB
 

Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selenium Training | Edureka

  • 1. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
  • 2. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Topics to be covered… 01 Introduction to Xpath 02 XML Document 03 Benefits of Xpath 04 Syntax & Terminology 05 Types of Xpath 06 Xpath Functions
  • 4. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Introduction To Xpath XPath can be also defined as XML path It consists of a path expression along with some conditions Xpath is a language to query XML documents Important strategy to locate elements in Selenium
  • 6. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training XML Document <bookstore> <book category= “cooking”> <title lang=“en”>Everyday Chinese</title> <author>K.S.Bose</author> <book> <book category= “children”> <title lang=“en”>Harry Potter</title> <author>J.K. Rowling</author> <book>
  • 7. bookstore book (category: cooking) author ( K.S Bose) author (J.K. Rowling) title (Everyday Chinese) book (category: children) title (Harry Potter) XML Tree
  • 8. bookstore book (category: cooking) author ( K.S Bose) author (J.K. Rowling) title (Everyday Chinese) book (category: children) title (Harry Potter) XML Tree Xpath = /bookstore/book[@category=‘children’]/author
  • 9. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Benefits of Xpath Queries are compact Queries are easily parsed Queries are easy to read & type Queries do not return repeated nodes Syntax is simple for simple and common cases You can uniquely identify any node in XML Document 1 2 3 4 5 6
  • 11. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Syntax and Terminology Xpath=/tagname[@Attribute=‘Value’] Select current node Select attributes Value of an attribute Attribute Name Tagname like input, div, img etc
  • 13. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Types of Xpath Relative Xpath Absolute Xpath
  • 14. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Types of Xpath Relative Xpath Absolute Xpath It is the direct way to find the element, but the disadvantage of the absolute XPath is that if there are any changes made in the path of the element then that XPath gets failed. Ex: /html/body/div[1]/section/div[1]/div
  • 15. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Types of Xpath Relative Xpath Absolute Xpath For, Relative Xpath the path starts from the middle of the HTML DOM structure. It starts with the double forward slash (//), which means it can search the element anywhere at the webpage Ex: //input[@id=‘ap_email’]
  • 17. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training <bookstore> <book category= “cooking”> <title lang=“en”>Everyday Chinese</title> <author>K.S.Bose</author> <book> <book category= “children”> <title lang=“en”>Harry Potter</title> <author>J.K. Rowling</author> <book> Xpath Functions
  • 18. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Xpath Functions text() starts-with() contains( )
  • 19. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Xpath Functions text() starts-with() contains( ) contains() is a method used in XPath expression. It is used when the value of any attribute changes dynamically, for example, login information. Xpath=//*[contains(@type,'sub')] Syntax:
  • 20. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Xpath Functions text() contains( ) starts-with() starts-with function finds the element whose attribute value changes on refresh or any operation on the webpage. Xpath=//label[starts-with(@id,’message')] Syntax:
  • 21. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Xpath Functions starts-with() contains( ) text() In this expression, with text function, we find the element with exact text match as shown below. In our case, we find the element with text "UserID". Syntax: Xpath=//td[text()=’UserID’]