Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
RSelenium-使用xpath选择父元素_R_Xpath_Rselenium - Fatal编程技术网

RSelenium-使用xpath选择父元素

RSelenium-使用xpath选择父元素,r,xpath,rselenium,R,Xpath,Rselenium,我正在尝试通过使用RSelenium的按钮捕获网页上可用的csv。相关的html是: <a ng-click='download()'><i class='csv-download'></i> Download</a> 我认为,要自动按下按钮,我需要选择父元素a元素,但我不知道如何做到这一点xpath似乎是最好的方法: remDr$findElement(using = 'xpath', "//i[@class='csv-download']/p

我正在尝试通过使用RSelenium的按钮捕获网页上可用的csv。相关的html是:

<a ng-click='download()'><i class='csv-download'></i> Download</a>
我认为,要自动按下按钮,我需要选择父元素
a
元素,但我不知道如何做到这一点<代码>xpath似乎是最好的方法:

remDr$findElement(using = 'xpath', "//i[@class='csv-download']/parent::*")
Error:   Summary: NoSuchElement
     Detail: An element could not be located on the page using the given search parameters.
     class: org.openqa.selenium.NoSuchElementException

xpath公式一定有问题。感谢您的帮助。

您可以继续使用CSS选择器,并依靠
ng click
属性:

remDr$findElement(using = 'css selector', "a[ng-click*=download]")
其中,
*=
表示“包含”


但是,要回答您的问题,请使用

remDr$findElement(using = 'xpath', "//i[@class='csv-download']/..")
remDr$findElement(using = 'xpath', "//i[@class='csv-download']/..")