Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSelenium through docker

My OS is windows 8.1 and I have the version 3.3.3 of R.

I have installed the RSelenium packages and I try to run it using this:

library("RSelenium")
#start RSelenium server
startServer()
checkForServer()

and I receive this error:

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.

Is there anything changed in the way RSelenium opens? I search for the error and I found only this but it doesn't help me. What can I do?

Also an alternative I tried is to download the chromedrive from here 'https://sites.google.com/a/chromium.org/chromedriver/downloads'

and using this script: require(RSelenium) cprof <- getChromeProfile("C:/Users/Peri/Desktop/chromedriver/chromedriver.exe", "Profile 1")

require(RSelenium)
remDr <- remoteDriver(remoteServerAddr = "localhost" 
                      , port = 4444
                      , browserName = "chrome", extraCapabilities = cprof
)
remDr$open()

and I receive this error:

Error in checkError(res) : 
  Couldnt connect to host on http://localhost:4444/wd/hub.
  Please ensure a Selenium server is running.

what can I do to run chrome instead of the pre-default browser Firefox?

like image 549
Keri Avatar asked Nov 08 '22 00:11

Keri


1 Answers

You need to use the function rsDriver. The Selenium Version wants you to use Docker (which I also would recommend), but if you are not familiar with this you can go this way.

rsdriver will manage the binaries needed for running a Selenium Server. This provides a wrapper around the wdman::selenium function.

Here is what you have to do to start a Chrome Browser:

driver<- rsDriver()
remDr <- driver[["client"]]

And then you can work with it:

remDr$navigate("http://www.google.de")
remDr$navigate("http://www.spiegel.de")

And stop it:

remDr$close()
like image 112
DanielS Avatar answered Nov 15 '22 07:11

DanielS