R RSelenium / seleniumPipes未知错误:找不到Chrome二进制文件

时间:2019-04-09 15:16:33

标签: r selenium selenium-chromedriver rselenium

我尝试使用Win10上的Chrome浏览器在R中连接Selenium。

我安装了Chrome 74.0.3729.61,并将chrome.exe路径添加到了环境变量中。

devtools::install_github("johndharrison/seleniumPipes")
devtools::install_github("ropensci/Rselenium")

#start selenium
selServ <- selenium()
# check ports
selServ$log()$stderr 
# conect using port
sel <- remoteDr(browserName = "chrome", port = 4567)

给我以下错误消息:

Called  newSession  - Try no:  1  of  3 

Called  newSession  - Try no:  2  of  3 

Called  newSession  - Try no:  3  of  3 
Error detected:
Response status code : 500 
Selenium Status code:  13 
Selenium Status summary:  UnknownError 
Selenium Status detail:  An unknown server-side error occurred while processing the command. 
Selenium message:  unknown error: cannot find Chrome binary
  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 40 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: ... , os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: driver.version: unknown 
Please check the response with errorResponse()
Please check the content returned with errorContent()

我找到了一些有关Python(Cannot find Chrome binary with Selenium in Python for older versions of Google Chrome)和c#(Selenium WebDriver - Could not find Chrome binary)的指南,但是,我不知道如何在R中实现它。

1 个答案:

答案 0 :(得分:2)

恕我直言,在使用硒之前,您需要下载并运行chomedriver.exe(如果您使用的是Windows 10,如上所述)。
您可以尝试以下解决方案吗?

解决方案1.在命令窗口上

java -Dwebdriver.chrome.driver =“ C:/ {yourPath} /selenium/chromedriver.exe” -jar“ C:/ {yourPath} /selenium/selenium-server-standalone-3.141.59.jar”-端口4567

解决方案2.直接使用R脚本

rstudioapi::terminalExecute('java -Dwebdriver.chrome.driver="C:/{yourPath}/selenium/chromedriver.exe" -jar "C:/{yourPath}/selenium/selenium-server-standalone-3.141.59.jar" -port 4567')

是的,两者都是完全相同的命令。您可以使用任何人。