[英]Get the value from xpath in selenium
How can I get the value from xpath in Selenium. 如何从Selenium中的xpath获取值。
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. 我正在传递表的位置,例如table> tr> td,但是使用String时出现错误。
Your answer need more precision. 您的答案需要更精确。 If "by value" you mean "text", you can have it with
getText()
method (it return the innerHTML
): 如果“按值”表示“文本”,则可以使用
getText()
方法获取它(它返回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. 编辑:btw,
table > tr > td
不是有效的xpath字符串。 It should be //table/tr/td
应该是
//table/tr/td
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.