Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Advance xpath


Published on

Advance Xpath Processing

Published in: Technology
  • Be the first to comment

Advance xpath

  1. 1. Advance Xpath Processing Suresh
  2. 2. What is Xpath XPath is a syntax used for selecting parts of an XML document The way XPath describes paths to elements issimilar to the way an operating system describes paths to filesXPath is almost a small programming language; it has functions and expressions XPath is a W3C standard
  3. 3. Html page
  4. 4. Using contains to search text
  5. 5. Using starts-with to search attribute value /html/body/div/table[3]/tbody/tr/td
  6. 6. Using Operator//div[contains(@class,pagination)]//a[contains(.,>) and not(contains(.,|))]
  7. 7. Using Functions //td[contains(.,Chapter)][position() =2] //td[contains(.,Chapter)][2]
  8. 8. Axes (outline View)Starting from a given node, the self, preceding, following, ancestor,and descendant axes form a partition of all the nodes
  9. 9. Axes (outline View) SelfPreceding
  10. 10. Axes (outline View) Following Ancestor
  11. 11. Axes (outline View) Descendant
  12. 12. Selecting using xpath Selecting from dropdown listdriver.findElement(By.xpath("//select/option[contains(.,pc)]")) Selecting radio button driver.findElement(By.xpath("//input[contains(@id,red) and @type=radio]")).click(); Selecting checkbox driver.findElement(By.xpath("//input[contains(@name,vehicle) and contains(@value,Nothing)]")).click();
  13. 13. Advantage of smart xpath processing Test case to click first chapterdriver.findElement(By.xpath(“/html/body/div/table[3]/tbody/tr/td”)).click(); or driver.findElement(By.xpath(“//td[contains(.,Chapter)][1]”)).click();  Maintenance is easy  Debugging is easy  Saves time and energy  Reduces the documentation time