0
如何從硒中的xpath獲取值?從硒中的xpath獲取值
public void DummyFunc(String startDate){
String test;
test=driver.findElement(By.xpath("//startDate"));
}
我正在傳遞table> tr> td表的位置,但在使用String時出現錯誤。
如何從硒中的xpath獲取值?從硒中的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()
}
編輯: 順便說一句,table > tr > td
不是有效的XPath字符串。它應該是//table/tr/td