RSelenium没有连接

时间:2016-08-06 02:01:00

标签: r selenium rselenium

我在尝试连接RSelenium软件包时遇到问题:

> checkForServer()
> startServer()
$stop
function () 
{
    tools::pskill(selPID)
}
<environment: 0x00000000039724d8>

$getPID
function () 
{
    return(selPID)
}
<environment: 0x00000000039724d8>

> remDr <- remoteDriver()
> remDr$open()
[1] "Connecting to remote server"
Error:   Summary: UnknownError
     Detail: An unknown server-side error occurred while processing the command.
     class: org.openqa.selenium.WebDriverException

我已经在我的计算机中配置了Java,但是RSelenium仍然失败了。我在这个网页上看了很多帖子,但我仍然没有解决方案。我能做什么?我的电脑是带有Windows 10 Home Single的华硕X555LB。我附上会议信息:

    > sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Spanish_Colombia.1252  LC_CTYPE=Spanish_Colombia.1252   
[3] LC_MONETARY=Spanish_Colombia.1252 LC_NUMERIC=C                     
[5] LC_TIME=Spanish_Colombia.1252    

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

other attached packages:
[1] rvest_0.3.2     xml2_1.0.0      RSelenium_1.4.0 XML_3.98-1.4    RJSONIO_1.3-0  
[6] RCurl_1.95-4.8  bitops_1.0-6    plyr_1.8.4      reshape_0.8.5  

loaded via a namespace (and not attached):
[1] httr_1.2.1     magrittr_1.5   R6_2.1.2       tools_3.3.0    Rcpp_0.12.6   
[6] caTools_1.17.1

感谢您的帮助。

更新

library(seleniumPipes)
> remDr <- remoteDr()
Error detected:
Response status code : 500 
Selenium class exception: org.openqa.selenium.WebDriverException 
Selenium Status code:  13 
Selenium Status summary:  UnknownError 
Selenium Status detail:  An unknown server-side error occurred while processing the command. 
Selenium message:  Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: WIN10
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'DESKTOP-UPMNBBN', ip: '192.168.0.27', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_101'
Driver info: driver.version: FirefoxDriver 
Please check the response with errorResponse()
Please check the content returned with errorContent()
Error in checkResponse(res) : Selenium Server error

1 个答案:

答案 0 :(得分:0)

您可以安装seleniumPipes并检查它可能给出的任何错误的输出:

devtools::install_github("johndharrison/seleniumPipes")
selServ <- RSelenium::startServer()
library(seleniumPipes)
remDr <- remoteDr()
remDr %>% go("http://www.google.com/ncr")
remDr %>% deleteSession()
selServ$stop()

更新

seleniumPipes的输出表明selenium驱动程序版本为2.53.1。该消息还指示无法找到firefox二进制文件。您可以使用firefox二进制路径作为JVM的参数 startServer(需要dev版本)。

selServ <- RSelenium::startServer(javaargs = c("-Dwebdriver.firefox.bin='C:\\YOURDIRPATH\\firefox.exe'"))

或者手动启动selenium二进制文件:

java -Dwebdriver.firefox.bin="C:\YOURDIRPATH\firefox.exe" -jar "selenium-server-standalone.jar"