Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
677 views
in Technique[技术] by (71.8m points)

r - How to open Google Chrome with RSelenium?

I am using RSelenium and I want to open and navigate Google Chrome. However, I always get an error when I want to open the browser from R. The following code is used:

library("RSelenium")
startServer()
mybrowser <- remoteDriver(browserName = "chrome")
mybrowser$open()

[1] "Connecting to remote server"
Error:   Summary: UnknownError
 Detail: An unknown server-side error occurred while processing the command.
 class: java.lang.IllegalStateException

The same code works for Firefox. What can I do about it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Even though Google Chrome is installed, there is still something missing that is needed by Selenium. This is the "chromedriver". "chromedriver" can be downloaded on this website. Currently, the most recent version is 2.25. For instance, if one is using Windows, the file "chromedriver_win32.zip" needs to be downloaded.

When the file is downloaded, extract the file in it, i.e. "chromedriver.exe". Place "chromedriver.exe" where you want it to be. I put it in "User/Documents/R".

In the last step, you need to add the folder where "chromedriver.exe" is located to the system path. A description for adding a folder to the system path can be found here.

Now, one can restart R and run the code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...