Testing 从selenium中的xpath获取值
如何从Selenium中的xpath获取值Testing 从selenium中的xpath获取值,testing,selenium,Testing,Selenium,如何从Selenium中的xpath获取值 public void DummyFunc(String startDate){ String test; test=driver.findElement(By.xpath("//startDate")); } 我正在传递表的位置,如table>tr>td,但在使用String时出现错误 你的答案需要更精确。如果“by value”是指“text”,则可以使用getText()方法(它返回
public void DummyFunc(String startDate){
String test;
test=driver.findElement(By.xpath("//startDate"));
}
我正在传递表的位置,如table>tr>td,但在使用String时出现错误 你的答案需要更精确。如果“by value”是指“text”,则可以使用
getText()
方法(它返回innerHTML
):
编辑:
顺便说一句,table>tr>td
不是有效的xpath字符串。它应该是//table/tr/td
public void DummyFunc(String startDate){
String test;
test = driver.findElement(By.xpath("//"+startDate));
return test.getText()
}