0

我正在尝试使用 RSelenium,但在尝试启动远程驱动程序时遇到以下错误。任何关于我需要修复的建议将不胜感激,

library(RSelenium)
RSelenium::checkForServer()
RSelenium::startServer()
require(RSelenium)

system("defaults write org.R-project.R force.LANG en_US.UTF-8")
remote.driver <- remoteDriver(remoteServerAddr = "localhost" , port = 4455, browserName = "firefox")
startServer(args = c("-port 4455"), log = FALSE, invisible = FALSE)
remote.driver$open()

>[1] "Connecting to remote server"
Error:   Summary: UnknownError
     Detail: An unknown server-side error occurred while processing the command.
     class: java.util.zip.ZipException

我的会话详细信息如下

>system("java -version")
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

>sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RSelenium_1.3.5 XML_3.98-1.3    RJSONIO_1.3-0   RCurl_1.95-4.6  bitops_1.0-6   

loaded via a namespace (and not attached):
[1] tools_3.2.0    caTools_1.17.1
4

1 回答 1

2

首先尝试停止两台服务器:

browseURL("http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer")
browseURL("http://localhost:4455/selenium-server/driver/?cmd=shutDownSeleniumServer")

然后:在您尝试连接的端口上打开服务器,如下所示(请参阅
?RSelenium::startServer()

startServer()
# example of commandline passing
startServer(args = c("-port 4455"), log = FALSE, invisible = FALSE)
remDr <- remoteDriver(browserName = "firefox", port = 4455)
remDr$open()

我猜您的代码有什么问题:
我认为您以错误的顺序运行命令。

您确实在端口 4444 上启动了 Selenium 服务器(RSelenium::startServer()您的第 3 行 - 这默认为端口 = 4444。)然后您尝试在端口 4455(您的第 6 行)上运行远程驱动程序

remote.driver <- remoteDriver(remoteServerAddr = "localhost" , port = 4455, browserName = "firefox")

在尝试在错误的端口上打开连接后,您最终在端口 4455(您的第 7 行)上启动服务器。

于 2015-12-25T18:10:13.243 回答