[英]Get the value from xpath in selenium
如何從Selenium中的xpath獲取值。
public void DummyFunc(String startDate){
String test;
test=driver.findElement(By.xpath("//startDate"));
}
我正在傳遞表的位置,例如table> tr> td,但是使用String時出現錯誤。
您的答案需要更精確。 如果“按值”表示“文本”,則可以使用getText()
方法獲取它(它返回innerHTML
):
public void DummyFunc(String startDate){
String test;
test = driver.findElement(By.xpath("//"+startDate));
return test.getText()
}
編輯:btw, table > tr > td
不是有效的xpath字符串。 應該是//table/tr/td
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.