2. What is Xpath
XPath is a syntax used for selecting parts of an
XML document
The way XPath describes paths to elements is
similar to the way an operating system describes
paths to files
XPath is almost a small programming language; it
has functions and expressions
XPath is a W3C standard
12. Selecting using xpath
Selecting from dropdown list
driver.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. Advantage of smart xpath processing
Test case to click first chapter
driver.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