Note: this answer is meant for Windows
When trying to run the deprecated checkForServer()
Selenium offers two options:
see:
RSelenium::checkForServer()
# Error: checkForServer is now defunct. Users in future can find the function in
# file.path(find.package("RSelenium"), "examples/serverUtils"). The
# recommended way to run a selenium server is via Docker. Alternatively
# see the RSelenium::rsDriver function.
Everybody seems to have issues with rsDriver and Docker is the recommended option so we'll go this route:
- install docker
- run it, restart computer as requested
- pull image by running in command line:
docker pull selenium/standalone-firefox
(or chrome
instead of firefox
) or in R shell('docker pull selenium/standalone-firefox')
- start server by running in command line:
docker run -d -p 4445:4444 selenium/standalone-firefox
or in R shell('docker run -d -p 4445:4444 selenium/standalone-firefox')
- Then run
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "firefox'")
. The doc suggests something different with a virtual machine but i couldn't get it to work.
With this I was set, here is my code:
shell('docker run -d -p 4445:4444 selenium/standalone-firefox')
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "firefox")
remDr$open()
remDr$navigate("http://www.google.com/ncr")
remDr$getTitle()
# [[1]]
# [1] "Google"
The doc for more info:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…