How can I get the value from xpath in Selenium.
public void DummyFunc(String startDate){
String test;
test=driver.findElement(By.xpath("//startDate"));
}
I am passing the location of the table like table > tr > td but I am getting an error when I use String.
Your answer need more precision. If "by value" you mean "text", you can have it with getText()
method (it return the innerHTML
):
public void DummyFunc(String startDate){
String test;
test = driver.findElement(By.xpath("//"+startDate));
return test.getText()
}
edit : btw, table > tr > td
is not a valid xpath string. It should be //table/tr/td
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.