我尝试使用 RSelenium 包和 Chrome 驱动程序打开远程驱动程序,但遇到以下错误:
Error: Summary: UnknownError
Detail: An unknown server-side error occurred while processing the command.
class: java.lang.IllegalStateException
这个问题之前已经在 stackoverflow 上被问过,但是 solution (我完全尝试过)没有用。我也咨询过this和 this .
我的R基本代码如下。错误发生在以下行 remDr$open()
之后。
install.packages("RSelenium")
library(RSelenium)
checkForServer()
startServer()
Sys.sleep(5.0)
remDr <- remoteDriver( browserName="chrome" )
remDr$open()
规范:
- R:v.3.3.0
- 使用 RStudio v.0.99.902 在 R 中工作
- 操作系统:OSX El Capital 10.11.3
- Java:1.8.92.14
- 我还下载了 chrome 驱动程序 v2.21 here 。它目前位于应用程序内自己的文件夹中。
为了解决这个问题,我尝试过:
startServer()
的两个替代版本下面的命令。第一个抛出了同样的错误,第二个也告诉我No Selenium Server binary exists. Run checkForServer or start server manually.
-
startServer(args = c("-Dwebdriver.chrome.driver=/mypath/to/chromedriver.exe") , log = FALSE, invisible = FALSE)
- 和
startServer(dir = FALSE, args = c("-Dwebdriver.chrome.driver=/mypath/to/chromedriver.exe") , log = FALSE, invisible = FALSE)
-
- 在终端中运行以下命令(并在运行 R 代码时使终端保持打开状态):
java -jar /mypath/to/selenium-server-standalone.jar -Dwebdriver.chrome.driver=/mypath/to/chromedriver.exe
。这引发了同样的错误。 - 创建
.command
文件包含我之前在上面 (2) 终端中输入的信息,并在 R 中调用该文件,如下所示。
.
install.packages("RSelenium")
library(RSelenium)
system(paste("open","/mypath/command.command")
remDr <- remoteDriver( browserName="chrome" )
remDr$open()
这导致了以下错误 The file could not be executed because you do not have appropriate access privileges.
导航到 Finder 中的 .command 文件并将所有共享和权限更改为读取和写入并没有更改错误消息。
重新安装所有组件 - Chrome 驱动程序、Selenium
.jar
文件、包RSelenium
。重新启动 R。更新 R 和 RStudio。像这样使用默认的远程驱动程序(Firefox,我相信)
remDr <- remoteDriver$new()
。不同的错误:class: org.openqa.selenium.WebDriverException
。更新 Firefox 以帮助解决上述 5 个问题,但没有效果。
如果有帮助,我们将不胜感激。
最佳答案
此处违反规则要求澄清。但这个问题让我发疯。您能否列出您在使用时所使用的所有内容的版本?
对我来说:
R 3.3.0 GUI 1.68 Mavericks 构建
RStudio 版本 0.99.902
OSX El Capital 10.11.5
Java:1.8.0_91
selenium-server-standalone-2.53.1.jar
FF 47.0(也尝试过 FF 46.0)
仍然导致 org.openqa.selenium.firefox.NotConnectedException
关于java - RSelenium java.lang.IllegalStateException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37603388/