Successfully reported this slideshow.
Your SlideShare is downloading. ×

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

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

YouTube videos are no longer supported on SlideShare

View original on YouTube

JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Topics to be covered…
01 Introduction to Xpath
02 XML Do...
Upcoming SlideShare
X Path in Selenium
X Path in Selenium
Loading in …3
×

Check these out next

1 of 23 Ad

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

(** Selenium Training:
https://www.edureka.co/testing-with-selenium-webdriver **)
This Edureka PPT on Xpath Tutorial talks about Xpath fundamentals and steps involved in writing a Xpath Script. It also gives a brief idea on types of Xpath, Xpath Functions along with an example.
Following topics are covered in this tutorial:

Introduction to Xpath
XML DocumentX
Xpath Syntax
Types of Xpath
Xpath Functions


Selenium playlist: https://goo.gl/NmuzXE

(** Selenium Training:
https://www.edureka.co/testing-with-selenium-webdriver **)
This Edureka PPT on Xpath Tutorial talks about Xpath fundamentals and steps involved in writing a Xpath Script. It also gives a brief idea on types of Xpath, Xpath Functions along with an example.
Following topics are covered in this tutorial:

Introduction to Xpath
XML DocumentX
Xpath Syntax
Types of Xpath
Xpath Functions


Selenium playlist: https://goo.gl/NmuzXE

Advertisement
Advertisement

More Related Content

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

Advertisement

More from Edureka! (20)

Recently uploaded (20)

Advertisement

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

  1. 1. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
  2. 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
  3. 3. Introduction to
  4. 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
  5. 5. XML Document
  6. 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. 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. 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. 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
  10. 10. Syntax & Terminology of
  11. 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
  12. 12. Types of
  13. 13. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Types of Xpath Relative Xpath Absolute Xpath
  14. 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. 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’]
  16. 16. 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
  17. 17. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Xpath Functions text() starts-with() contains( )
  18. 18. 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:
  19. 19. 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:
  20. 20. 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’]

×