最新版本的RSelenium和Firefox

时间:2016-08-07 08:30:51

标签: r selenium firefox rselenium

当我尝试打开RSelenium时,我收到此错误

[1] "Connecting to remote server"
Error:   Summary: UnknownError
     Detail: An unknown server-side error occurred while processing the command.
     class: org.openqa.selenium.firefox.NotConnectedException

我的Firefox版本是

Firefox version: 480b10

根据this,我尝试更新服务器版本

library("RSelenium")
startServer()
unlink(system.file("bin", package = "RSelenium"), recursive = T)
checkForServer(update = TRUE)
remDr <- remoteDriver()
Sys.sleep(5)
remDr$open()
Sys.sleep(5)

但问题仍然存在。有人面对这个问题吗?任何可能的解决方案?

1 个答案:

答案 0 :(得分:2)

从Firefox 48开始,需要使用Gecko驱动程序/牵线木偶来运行带有Selenium的Firefox。

如果你有Firefox 48,你可以按如下方式运行gecko驱动程序:

参阅指南

  1. https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
  2. https://github.com/mozilla/geckodriver/releases
  3. 下载相关的壁虎驱动程序
  4. 将其添加到PATH或在启动二进制文件时参考位置(见下文)
  5. # get beta selenium standalone
    
    RSelenium::checkForServer(beta = TRUE)
    # assume gecko driver is not in our path (assume windows and we downloaded to docs folder)
    # if the driver is in your PATH the javaargs call is not needed
    selServ <- RSelenium::startServer(javaargs = c("-Dwebdriver.gecko.driver=\"C:/Users/john/Documents/geckodriver.exe\""))
    remDr <- remoteDriver(extraCapabilities = list(marionette = TRUE))
    remDr$open()
    ....
    ....
    remDr$close()
    selServ$stop()  
    

    以上目前需要RSelenium的开发版本。或者,您可以从http://selenium-release.storage.googleapis.com/index.html下载Selenium二进制文件。选择当前使用Firefox 48运行的3.0 beta 2二进制文件。运行二进制文件

    java -Dwebdriver.gecko.driver=C:/Users/john/Documents/geckodriver.exe -jar selenium-server-standalone-3.0.0-beta2.jar