Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Testing 从selenium中的xpath获取值_Testing_Selenium - Fatal编程技术网

Testing 从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()方法(它返回

如何从Selenium中的xpath获取值

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()
}