【问题标题】:Unable to click on element using (R)Selenium无法使用 (R)Selenium 点击元素
【发布时间】:2018-04-18 11:20:26
【问题描述】:

我正在尝试使用 RSelenium 查找元素

remDr <- remoteDriver(remoteServerAddr = "192.168.99.100", port = 4445L,
                      browserName = "chrome")
remDr$open()
url <- "https://sudskapraksa.csp.vsrh.hr/decisionPdf?id=090216ba8084ca52"
remDr$navigate(url)

有一个验证码图片(如果您没有看到它,请尝试执行 10 次导航部分)我尝试选择使用:

  captcha_element <- remDr$findElement(using = "css selector", "img[id='captchaImg']")$clickElement()
  captcha_element <- remDr$findElement(using = "id", "captchaImg")$clickElement()
  captcha_element <- remDr$findElement(using = "xpath", "//*[@id='captchaIm']")$clickElement()

但它总是返回错误。

【问题讨论】:

  • trying to find element .. 究竟是哪个元素?
  • 验证码图片。假设您只想单击验证码图像。如果您没有看到验证码,请尝试执行 10 次导航部分

标签: r selenium selenium-webdriver web-scraping rselenium


【解决方案1】:

根据您的代码试验和后续评论更新来识别 验证码图像,您可以使用以下 定位器策略,但您无法调用粗略 click 事件 因为没有任何元素属性包含任何此类事件:

captcha_element <- remDr$findElement(using = "css selector", "img#captchaImg")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-10
    • 1970-01-01
    • 2021-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-25
    相关资源
    最近更新 更多