为什么RSelenium不能按此按钮?(Why can’t RSelenium press this button?)
我正在尝试使用RSelenium在网站上自动浏览,以便检索最新的计划发布日期。 我的问题在于,当我访问URL时会弹出一个年龄检查。 页面(年龄检查页面)由两个按钮组成,我没有成功通过RSelenium点击。 到目前为止我使用的代码附在下面,这个问题的解决方案是什么?
#Varialble and URL s4 <- "https://www.systembolaget.se" #Start Server rd <- rsDriver() remDr <- rd[["client"]] #Load Page remDr$navigate(s4) webE <- remDr$findElements("class name", "action") webE$isElementEnabled() webE$clickElement()I’m trying to automate browsing on a site with RSelenium in order to retrieve the latest planned release dates. My problem lies in that there is an age-check that pops up when I visit the URL. The page(age-check-page) concists of two buttons, which I haven’t succeeded to click on through RSelenium. The code that I use thus far is appended below, what is the solution for this problem?
#Varialble and URL s4 <- "https://www.systembolaget.se" #Start Server rd <- rsDriver() remDr <- rd[["client"]] #Load Page remDr$navigate(s4) webE <- remDr$findElements("class name", "action") webE$isElementEnabled() webE$clickElement()最满意答案
您需要更准确地定位选择器:
#Varialble and URL s4 <- "https://www.systembolaget.se" #Start Server rd <- rsDriver() remDr <- rd[["client"]] #Load Page remDr$navigate(s4) webE <- remDr$findElement("css", "#modal-agecheck .action.primary") webE$clickElement()You need to more accurately target the selector:
#Varialble and URL s4 <- "https://www.systembolaget.se" #Start Server rd <- rsDriver() remDr <- rd[["client"]] #Load Page remDr$navigate(s4) webE <- remDr$findElement("css", "#modal-agecheck .action.primary") webE$clickElement()更多推荐
发布评论