简体   繁体   English

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

[英]R RSelenium/seleniumPipes Unknown error: cannot find Chrome binary

I try to connect with Selenium in R using the Chrome browser on Win10.我尝试在 Win10 上使用 Chrome 浏览器连接 R 中的 Selenium。

I installed Chrome 74.0.3729.61 and added the chrome.exe path to the Environment Variables.我安装了 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)

gives me the following error message:给我以下错误消息:

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()

I found some guidance for Python ( Cannot find Chrome binary with Selenium in Python for older versions of Google Chrome ) and c# ( Selenium WebDriver - Could not find Chrome binary ), however, I do not know how to implement it in R.我找到了一些关于 Python( 无法在旧版本的 Google Chrome 中使用 Selenium 在 Python 中找到 Chrome 二进制文件)和 c#( Selenium WebDriver - 找不到 Chrome 二进制文件)的指导,但是,我不知道如何在 R 中实现它。

IMHO you need to download and run chomedriver.exe(if you are using Windows 10, as you mentioned) before to use selenium.恕我直言,在使用 selenium 之前,您需要下载并运行 chomedriver.exe(如果您使用的是 Windows 10,正如您所提到的)。
Could you try below solution?您可以尝试以下解决方案吗?

Solution 1. on command window解决方案1.在命令窗口

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

or或者

Solution 2. direct use R script解决方案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')

Yes, both are same command exactly.是的,两者都是相同的命令。 You are able to use anyone you want.你可以使用任何你想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM