4

I run Selenium with docker like this:

docker run -d -p 4445:4444 selenium/standalone-firefox:2.53.1

and this line remDr$findElement(using = "class", "percent") in the following R Script works fine.

library("tidyverse")
library("RSelenium")

# A Selenium server has to be running
# Works with: docker run -d -p 4445:4444 selenium/standalone-firefox:2.53.1
# Fails with: docker run -d -p 4445:4444 selenium/standalone-firefox:latest

remDr <- remoteDriver(port = 4445L)
remDr$open()

remDr$navigate("https://www.alternabank.ca/everyday-banking/high-interest-esavings")
webElem <- remDr$findElement(using = "class", "percent")
tmp <- webElem$getElementText()

remDr$close()

I kill that container and do: docker run -d -p 4445:4444 selenium/standalone-firefox:latest

And then run the same code again. This results in an error:

> webElem <- remDr$findElement(using = "class", "percent")
Error in .self$value[[1]] : subscript out of bounds

Why is this? How can I get my old code to work with the latest version of firefox. I need the newer version for some other things to work.

I also see that the name of the linux process changes from "firefox" to "Gecko".

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
ixodid
  • 2,180
  • 1
  • 19
  • 46
  • Is the remote server correctly starting up? Selenium is notoriously hard to exit properly. https://stackoverflow.com/questions/43991498/rselenium-server-signals-port-is-already-in-use Could it be a port being already in use? – Donald Seinen Oct 26 '21 at 03:56
  • I think the Selenium server starts correctly. In switching between the two containers, if I don't kill the old container I get a port in use error so I don't think that is the problem. – ixodid Oct 26 '21 at 04:04
  • Have you tried: `docker run -d -p 4445:4444 --shm-size="2g" selenium/standalone-firefox:latest` ? (giving it some extra RAM) – Brian Montgomery Oct 29 '21 at 23:57
  • I've monitored RAM usage on Digital Ocean and it's OK. – ixodid Oct 30 '21 at 01:45
  • I updated to latest and it broke my code as well. Win10 desktop no Digital Ocean and a completely different website. – Brian Montgomery Oct 30 '21 at 17:24
  • shouldn't `webElem <- remDr$findElement(using = "class", "percent")` actually be `webElem <- remDr$findElement(using = "class", value = "percent")` ? – djmonki Nov 01 '21 at 08:06
  • @djmonki No difference. "value" is assumed. – ixodid Nov 03 '21 at 01:31
  • I've been having trouble with :latest as well. Mine works with version 3, but not 4. So try, `selenium/standalone-firefox:3.141.59-20210929` – Brian Montgomery Nov 05 '21 at 23:50

1 Answers1

1

When you start the Selenium using the command:

docker run -d -p 4445:4444 selenium/standalone-firefox:2.53.1

Effectively, selenium/standalone-firefox:2.53.0 uses:

  • The legacy Firefox browser and the version was between Firefox 45.x to Firefox 47.x
  • If you have configured the docker container yourself, you are able to specify your own FIREFOX_VERSION while building it.
  • Marionette based GeckoDriver wasn't mandatory.

So, there's no issue in program execution.


But when you start the Selenium using the command:

docker run -d -p 4445:4444 selenium/standalone-firefox:latest

Marionette based GeckoDriver comes into play.

There are quite significant updates/modifications/changes between how the Legacy Firefox Browser was earlier run and how the GeckoDriver currently drives the browser now.

This should also explain why you see that the name of the linux process changes from "firefox" to "Gecko"

Additionally, you need to keep the GeckoDriver synchronized with the Firefox Browser and you can find a relevant detailed discussion in Selenium: How selenium identifies elements visible or not? Is is possible that it is loaded in DOM but not rendered on UI?


TL; DR

StandaloneFirefox 2.53.0 image hosted on hub.docker.com was updated and broke internal build

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352