1 / 23

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

(** Selenium Training: <br>https://www.edureka.co/testing-with-selenium-webdriver **) <br>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. <br>Following topics are covered in this tutorial: <br><br>Introduction to Xpath <br>XML DocumentX <br>Xpath Syntax <br>Types of Xpath <br>Xpath Functions <br><br><br>Selenium playlist: https://goo.gl/NmuzXE

EdurekaIN
Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Topics to be covered… 01 Introduction to Xpath 02 XML Document 03 Benefits of Xpath 04 Syntax & Terminology Types of Xpath 05 Xpath Functions 06 JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  3. Introduction to

  4. Introduction To Xpath Important strategy to locate elements in Selenium Xpath is a language to query XML documents It consists of a path expression along with some conditions XPath can be also defined as XML path JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  5. XML Document

  6. 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> JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  7. XML Tree bookstore book (category: cooking) book (category: children) title (Harry Potter) title (Everyday Chinese) author ( K.S Bose) author (J.K. Rowling)

  8. XML Tree bookstore book (category: cooking) book (category: children) title (Harry Potter) title (Everyday Chinese) author ( K.S Bose) author (J.K. Rowling) Xpath = /bookstore/book[@category=‘children’]/author

  9. Benefits of Xpath 1 Queries are compact 2 Queries are easily parsed 3 Queries are easy to read & type 4 Queries do not return repeated nodes 5 Syntax is simple for simple and common cases 6 You can uniquely identify any node in XML Document JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  10. Syntax & Terminology of

  11. Syntax and Terminology Select current node Select attributes Value of an attribute Xpath=/tagname[@Attribute=‘Value’] Tagname like input, div, img etc Attribute Name JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  12. Types of

  13. Types of Xpath Absolute Xpath Relative Xpath JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  14. Types of 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. Relative Xpath Ex: /html/body/div[1]/section/div[1]/div JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  15. Types of 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 Relative Xpath Ex: //input[@id=‘ap_email’] JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  16. Xpath Functions <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> JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  17. Xpath Functions contains( ) starts-with() text() JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  18. Xpath Functions contains( ) contains() is a method used in XPath expression. It is used when the value of any attribute changes dynamically, for example, login information. Syntax: starts-with() Xpath=//*[contains(@type,'sub')] text() JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  19. Xpath Functions contains( ) starts-with function finds the element whose attribute value changes on refresh or any operation on the webpage. starts-with() Syntax: Xpath=//label[starts-with(@id,’message')] text() JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  20. Xpath Functions contains( ) 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". starts-with() Syntax: Xpath=//td[text()=’UserID’] text() JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

More Related