I have been following the Docker/RSelenium tutorial here: https://docs.ropensci.org/RSelenium/articles/docker.html
I have successfully hosted my own Selenium server:
# sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0c673ba37477 selenium/standalone-chrome:88.0 "/opt/bin/entry_poin…" 3 minutes ago Up 3 minutes 5900/tcp, 0.0.0.0:4445->4444/tcp zealous_shannon
When I run the following commands, per the tutorial:
library(RSelenium)
remDr <- remoteDriver(port = 4445L)
remDr$open()
I get the following output with no error message:
[1] "Connecting to remote server"
$id
[1] NA
The expected output is:
## [1] "Connecting to remote server"
## $applicationCacheEnabled
## [1] TRUE
##
## $rotatable
## [1] FALSE
##
## $handlesAlerts
## [1] TRUE
##
## $databaseEnabled
## [1] TRUE
##
## $version
## [1] "45.0.2"
##
## $platform
## [1] "LINUX"
##
## $nativeEvents
## [1] FALSE
##
## $acceptSslCerts
## [1] TRUE
##
## $webdriver.remote.sessionid
## [1] "644c353a-34b8-4bb4-bcff-746df5a30af8"
##
## $webStorageEnabled
## [1] TRUE
##
## $locationContextEnabled
## [1] TRUE
##
## $browserName
## [1] "firefox"
##
## $takesScreenshot
## [1] TRUE
##
## $javascriptEnabled
## [1] TRUE
##
## $cssSelectorsEnabled
## [1] TRUE
##
## $id
## [1] "644c353a-34b8-4bb4-bcff-746df5a30af8"
This prevents me from proceeding with the tutorial. Any idea why my connection via the RemoteDriver is not working properly?
Set the connection parameters correctly for the operating system you are using and the browser. If the image is based on chrome
browser and the default configuration of the driver is firefox
.
To change this you will need to add the browserName = "chrome"
. I suggest to always add the server's IP address for clarity so, add remoteServerAddr = <<server IP>>
The way to find out what are the default parameters for the driver is to inspect the instantiated remote driver remDr
will show you what is the default configuration for the driver.
>remDr
$remoteServerAddr
[1] "localhost"
$port
[1] 4445
$browserName
[1] "firefox"
$version
[1] ""
$platform
[1] "ANY"
$javascript
[1] TRUE
$nativeEvents
[1] TRUE
$extraCapabilities
list()
So after setting the correct parameter, I was able to connect to the RSelenum on the exposed port.
library(RSelenium)
> remDr <- remoteDriver(
+ remoteServerAddr = "localhost",
+ port = 4445L,
+ browserName = "chrome")
> remDr$open()
[1] "Connecting to remote server"
$acceptInsecureCerts
[1] FALSE
$browserName
[1] "chrome"
$browserVersion
[1] "88.0.4324.150"
$chrome
$chrome$chromedriverVersion
[1] "88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784})"
$chrome$userDataDir
[1] "/tmp/.com.google.Chrome.egZzL9"
$`goog:chromeOptions`
$`goog:chromeOptions`$debuggerAddress
[1] "localhost:36841"
$networkConnectionEnabled
[1] FALSE
$pageLoadStrategy
[1] "normal"
$platformName
[1] "linux"
$proxy
named list()
$`se:options`
$`se:options`$cdp
[1] "http://172.17.0.2:4444/session/eaed604c5fae33476755e4ba3e1c1d9e/se/cdp"
$setWindowRect
[1] TRUE
$strictFileInteractability
[1] FALSE
$timeouts
$timeouts$implicit
[1] 0
$timeouts$pageLoad
[1] 300000
$timeouts$script
[1] 30000
$unhandledPromptBehavior
[1] "dismiss and notify"
$`webauthn:extension:largeBlob`
[1] TRUE
$`webauthn:virtualAuthenticators`
[1] TRUE
$id
[1] "eaed604c5fae33476755e4ba3e1c1d9e"