为什么我无法连接到 Selenium 服务器?

Why can't I connect to Selenium Server?

我的 RSelenuium 脚本今天停止工作,我不明白为什么。下面的代码是我通常用来启动服务器的代码。

library(RSelenium)

rd <- rsDriver(port = 4567L, browser = "chrome")

但现在我收到以下错误消息:

checkError(res) 错误: 无法连接到 http://localhost:4567/wd/hub 上的主机。 请确保 Selenium 服务器是 运行。 另外: 警告信息: 在 rsDriver(port = 4567L, browser = "chrome") 中: 无法确定服务器状态。

然后我尝试下面的代码:

selServ <- wdman::selenium(verbose = FALSE)
selServ$log()

然后出现以下错误:

$标准错误 [1] "Error: Invalid or corrupt jarfile C:\Users\Allan\AppData\Local\binman\binman_seleniumserver\generic.6.0/selenium-server-standalone-3.6.0.jar"

$标准输出 字符(0)

那么我该如何解决这个问题?

您可以使用 binman 软件包删除版本:

> binman::list_versions("seleniumserver")
$generic
 [1] "3.0.0"       "3.0.0-beta4" "3.0.1"       "3.1.0"       "3.2.0"      
 [6] "3.3.0"       "3.3.1"       "3.4.0"       "3.5.0"       "3.5.1"      
[11] "3.5.2"       "3.5.3"       "3.6.0"      

> binman::rm_version("seleniumserver", "generic", "3.6.0")
Removing version: 3.6.0 from platorm: generic

运行 rsDriver 将重新下载损坏的 JAR:

> rD <- rsDriver()
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
Creating directory: C:\Users\john\AppData\Local\binman\binman_seleniumserve...
Downloading binary: https://www.googleapis.com/download/storage/v1/b/seleni...

BEGIN: POSTDOWNLOAD
checking chromedriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking geckodriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking phantomjs versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
[1] "Connecting to remote server"

# clean up
rm(rD)
gc()