RSelenium findElement works with firefox:2.53.1 but not with firefox:latest

279 Views Asked by At

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".

1

There are 1 best solutions below

0
undetected Selenium On

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