Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.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
R 向元素发送按键_R_Selenium - Fatal编程技术网

R 向元素发送按键

R 向元素发送按键,r,selenium,R,Selenium,我试着从 在使用firefox firebug for google write box的firefox中,我可以看到以下内容来查找id: <input id="gs_htif0" class="gsfi" disabled="" autocomplete="off" aria-hidden="true" style="border: medium none; padding: 0px; margin: 0px; height: auto; width: 100%; position: a

我试着从

在使用firefox firebug for google write box的firefox中,我可以看到以下内容来查找id:

<input id="gs_htif0" class="gsfi" disabled="" autocomplete="off" aria-hidden="true" style="border: medium none; padding: 0px; margin: 0px; height: auto; width: 100%; position: absolute; z-index: 1; background-color: transparent; color: silver; transition: all 0.218s ease 0s; opacity: 0; text-align: left; left: 0px;" dir="ltr">

似乎您使用了不正确的xpath,谷歌搜索框的正确xpath是
/*[@id=“lst ib”]


希望它能解决您的问题。

Google搜索框正确的xpath是
/*[@id=“lst ib”]
,可能是您使用了不正确的帮助帮助帮助帮助。如果你想,请把它作为一个答案来标记它?太好了,我只是把它作为答案。
library("RSelenium")
startServer()
checkForServer()
remDr <- remoteDriver()
remDr$open()
remDr$navigate("https://www.google.com/")
webElem <- remDr$findElement(using = "xpath", "//*/input[@id = 'gs_htif0']")
webElem$sendKeysToElement(list("R Cran", "\uE007"))
Error:   Summary: InvalidElementState
     Detail: An element command could not be completed because the element is in an invalid state (e.g. attempting to click a disabled element).
     class: org.openqa.selenium.InvalidElementStateException