【问题标题】:RSelenium java.lang.IllegalStateExceptionRSelenium java.lang.IllegalStateException
【发布时间】:2016-06-02 22:52:06
【问题描述】:

我正在尝试使用带有 Chrome 驱动程序的 RSelenium 包打开远程驱动程序并遇到以下错误:

Error:   Summary: UnknownError
Detail: An unknown server-side error occurred while processing the command.
class: java.lang.IllegalStateException

之前在 stackoverflow 上已经提出过这个问题,但是 solution(我已经完全尝试过)没有用。我也咨询了thisthis

我在 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.21here。它目前位于应用程序中自己的文件夹中。

为了解决这个问题,我已经尝试过:

  1. 以下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)
  2. 在终端中运行以下命令(并在运行 R 代码时保持终端打开):java -jar /mypath/to/selenium-server-standalone.jar -Dwebdriver.chrome.driver=/mypath/to/chromedriver.exe。这引发了同样的错误。
  3. 创建一个.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 文件并将所有共享和权限更改为读写并没有更改错误消息。

  1. 重新安装所有组件 - Chrome 驱动程序、Selenium .jar 文件、包 RSelenium。重新启动 R。更新 R 和 RStudio。

  2. 使用像 remDr &lt;- remoteDriver$new() 这样的默认远程驱动程序(我相信是 Firefox)。不同的错误:class: org.openqa.selenium.WebDriverException

  3. 更新 Firefox 以帮助上述 5 无济于事。

我们将不胜感激。

【问题讨论】:

  • 不知道,但似乎您在尝试修复方面非常彻底。
  • 我在 Windows 上遇到同样的错误。使用startServer(log = FALSE, invisible = FALSE) 打开服务器控制台,然后您可能会遇到错误。它适用于 Firefox
  • 谢谢!我试过了(使用 Chrome 和 Firefox)。我没有打开“服务器控制台”(不确定这意味着什么),但我得到了一个不同的错误:org.openqa.selenium.WebDriverException。 @HubertL

标签: java r google-chrome selenium


【解决方案1】:

在这里违反规则要求澄清。但是这个问题让我发疯了。您能否列出您在使用时使用的所有内容的版本。

对我来说:

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

【讨论】:

  • 当然。版本与我在最初的问题中发布的版本相同。唯一的区别是我不再尝试使用 Chrome 驱动程序,而是让它与 Firefox 驱动程序一起工作。虽然我没有通过这篇文章澄清发生了什么,但其他人(在现实生活中)建议(a)使用 Firefox 更好,因为这是 RSelenium 的默认设置,并且不需要安装新驱动程序,并且(b) 关闭你的端口(即使你不认为你打开了一个端口)很重要。最后,我没有收到与您相同的错误,因此您可能正在处理其他问题。
  • 感谢您的回复。我终于为我修好了。需要 FF45。
  • 我也有问题,你是怎么解决的?
【解决方案2】:

以下解决了问题:

checkForServer()              
startServer( args = c( "-port 4455" ), log = FALSE, invisible = FALSE )
remDr <- remoteDriver( browserName="firefox", port=4455 )            
remDr$open( silent=T ) 

我不确定它为什么会起作用(也许有人可以回答这个问题),但这起到了作用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-16
    • 1970-01-01
    • 2018-11-22
    • 1970-01-01
    • 2015-06-23
    • 2017-08-06
    • 2017-11-10
    • 1970-01-01
    相关资源
    最近更新 更多