0% found this document useful (0 votes)
28 views

Sample Code For Download Explaining Xpath Text

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
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Sample Code For Download Explaining Xpath Text

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
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Sample code for download explaining

xpath text/siblings/parent
package Tests;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class testit {

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


// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver","C:\\work\\
chromedriver.exe");
WebDriver driver =new ChromeDriver();
driver.get("http://www.qaclickacademy.com/interview.php");
driver.findElement(By.xpath("//li[text()=' Selenium ']")).click();
driver.findElement(By.xpath("//ul[@class='responsive-tabs__list']/li[1]/
following-sibling::li[2]")).click();

System.out.println(driver.findElement(By.xpath(".//*[@id='tablist1-tab2']/
parent::ul")).getAttribute("role"));
//

}
}

You might also like