0% found this document useful (0 votes)
6 views1 page

XPath Examples for Selenium Download

The document provides sample code for using XPath to find text, siblings, and parent elements in Selenium. The code shows how to locate elements using text, following-sibling, and parent axis in XPath and retrieve attributes.

Uploaded by

SuprinAhluwalia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

XPath Examples for Selenium Download

The document provides sample code for using XPath to find text, siblings, and parent elements in Selenium. The code shows how to locate elements using text, following-sibling, and parent axis in XPath and retrieve attributes.

Uploaded by

SuprinAhluwalia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Sample code for download explaining

xpath text/siblings/parent
package Tests;

import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class testit {

public static void main(String[] args) throws InterruptedException {


// TODO Auto-generated method stub
[Link]("[Link]","C:\\work\\
[Link]");
WebDriver driver =new ChromeDriver();
[Link]("[Link]
[Link]([Link]("//li[text()=' Selenium ']")).click();
[Link]([Link]("//ul[@class='responsive-tabs__list']/li[1]/
following-sibling::li[2]")).click();

[Link]([Link]([Link](".//*[@id='tablist1-tab2']/
parent::ul")).getAttribute("role"));
//

}
}

You might also like