简体   繁体   中英

RSelenium is not working

I try to install and run a simple example for R Selenium package using this:

install.packages("RSelenium")
library("RSelenium")
startServer()
checkForServer()
startServer()
remDr <- remoteDriver(browserName = "Chrome")
remDr$open()

In the last code I receive this:

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

I tried some workarounds from google but nothing worked. What can I do?

From comments:

Click start
Select Control Panel > System
Select Advance system settings
Click Environment Variables...

Under System Variables
Scroll to Path and double click
At the end of Variable value: add ;C:\\path\\to\\directory that holds the chromedriver.exe file. Note the ; that separates the paths

Restart your R session and you should now be able to run:

> require(RSelenium)
  RSelenium::startServer()
  remDr <- remoteDriver(browserName = "chrome")
  remDr$open()

EDIT

For RSelenium to operate with chrome you first need to download chromedriver.exe you can download this from https://sites.google.com/a/chromium.org/chromedriver/downloads . Once downloaded unzip the folder and place chromedriver.exe where you would like to store it.

The directory that you store chromedriver.exe and add to your system PATH can be anywhere you choose. As stated in comments, for example, mine currently resides in C:\\Python27\\Scripts .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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