You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Docker+RSelenium调用getElementText()时遭遇'subscript out of bounds'错误的求助

使用Docker+RSelenium调用getElementText()时遭遇'subscript out of bounds'错误的求助

各位好,我去年用Docker搭配RSelenium从网站下拉菜单提取文本的代码今年突然失效了,调用getElementText()的时候一直弹出这个错误:

"Error in resContent[["status"]] : subscript out of bounds"

我在网上搜了一圈,没找到遇到同样问题的案例,下面是可复现的示例代码:

# Load libraries
library(tidyverse)
library(RSelenium)
library(rvest)

eCaps <- list(chromeOptions = list(
  args = c("--window-size=1920,1080",
           "--disable-extensions",
           "--proxy-server='direct://'",
           "--proxy-bypass-list=*",
           "--start-maximized",
           "--headless",
           "--desable-gpu",
           "--disable-dev-shm-usage",
           "--no-sandbox",
           "--ignore-certificate-errors"
  ),
  prefs = list("profile.default_content_settings.popups" = 0L,
               "download.prompt_for_download" = FALSE)
))

shell('docker run -d -p 4445:4444 selenium/standalone-chrome')

remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "chrome",
                      extraCapabilities = eCaps)
remDr$open()

remDr$navigate("https://demoqa.com/select-menu")

remDr$screenshot(display = TRUE)

WebElem <- remDr$findElement("id", "oldSelectMenu")

WebElemText <- WebElem$getElementText()

备注:内容来源于stack exchange,提问作者K S

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 12:39:37