【问题标题】:RSelenium through dockerRSelenium 通过 docker
【发布时间】:2017-08-06 06:19:56
【问题描述】:

我的操作系统是 windows 8.1,我的版本是 R.3.3.3。

我已经安装了 RSelenium 包并尝试使用它来运行它:

library("RSelenium")
#start RSelenium server
startServer()
checkForServer()

我收到此错误:

Error: checkForServer is now defunct. Users in future can find the function in 
file.path(find.package("RSelenium"), "examples/serverUtils"). The
recommended way to run a selenium server is via Docker. Alternatively
see the RSelenium::rsDriver function.

RSelenium 打开的方式有什么变化吗?我搜索错误,我只找到this,但这对我没有帮助。我能做什么?

我尝试过的另一种方法是从这里下载 chromedrive 'https://sites.google.com/a/chromium.org/chromedriver/downloads'

并使用此脚本: 需要(RS硒) cprof

require(RSelenium)
remDr <- remoteDriver(remoteServerAddr = "localhost" 
                      , port = 4444
                      , browserName = "chrome", extraCapabilities = cprof
)
remDr$open()

我收到此错误:

Error in checkError(res) : 
  Couldnt connect to host on http://localhost:4444/wd/hub.
  Please ensure a Selenium server is running.

如何运行 chrome 而不是默认浏览器 Firefox?

【问题讨论】:

标签: r selenium rselenium


【解决方案1】:

您需要使用函数rsDriver。 Selenium 版本希望你使用 Docker(我也会推荐),但如果你不熟悉这个,你可以这样做。

rsdriver 将管理运行 Selenium 服务器所需的二进制文件。这为 wdman::selenium 函数提供了一个包装器。

要启动 Chrome 浏览器,您必须执行以下操作:

driver<- rsDriver()
remDr <- driver[["client"]]

然后你就可以使用它了:

remDr$navigate("http://www.google.de")
remDr$navigate("http://www.spiegel.de")

然后停止:

remDr$close()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-16
    • 1970-01-01
    • 2022-08-17
    • 2017-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多