我试图通过Selenium在R中将文本输入弹出式窗口,但似乎找不到该在哪里做它。
library(RSelenium)
rD <- rsDriver(browser="firefox", port=4545L, verbose=F)
remDr[["client]]
remDr$navigate("http://www.espn.com/login")下一步真的把我搞糊涂了。基本上,当我尝试使用remDr$findElements(using = "xpath", value = "...")时,我没有运气。在检查页面时,我尝试从开发人员工具复制xpath,但得到了以下内容:
un_enter <- remDr$findElement(using = "xpath", "/html/body/div[1]/div/div/section/section/form/section/div[1]/div/label/span[2]/input")
Selenium message:Unable to locate element: /html/body/div[1]/div/div/section/section/form/section/div[1]/div/label/span[2]/input
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '4.0.0-alpha-2', revision: 'f148142cf8', time: '2019-07-01T21:30:10'
System info: host: 'LAPTOP-06J6R94A', ip: '192.168.1.167', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_341'
Driver info: driver.version: unknown
Error: Summary: NoSuchElement
Detail: An element could not be located on the page using the given search parameters.
class: org.openqa.selenium.NoSuchElementException
Further Details: run errorDetails method这可能是因为这些信息在弹出窗口吗?
发布于 2022-08-08 19:20:03
我自己已经想出来了!我没有叫正确的iframe。通过以下方法解决了这一问题:
webElem <- remDr$findElement("css", "iframe")
remDr$switchToFrame(webElem[[1]])
# code normally from herehttps://stackoverflow.com/questions/73282719
复制相似问题