ropensci / RSelenium

An R client for Selenium Remote WebDriver
https://docs.ropensci.org/RSelenium
341 stars 81 forks source link

Firefox Rselenium fails with Ubuntu 22.04 default firefox #258

Open nbarsch opened 1 year ago

nbarsch commented 1 year ago

In Ubuntu 22.04 the default firefox now comes via the dumpster fire that is Snap. To make RSelenium work with browser="firefox" by default without loading a custom profile, the apt version of firefox is required instead of the snap version.

When trying using the default firefox that comes with 22.04, RSelenium firefox launch fails:

A popup appears with "Your Firefox profile cannot be loaded. It may be missing or inaccessible."

The following error appears in R: Selenium message:Process unexpectedly closed with status 1 Build info: version: '4.0.0-alpha-2', revision: 'f148142cf8', time: '2019-07-01T21:30:10' System info: host: 'mycomputer', ip: 'removed', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-40-generic', java.version: '11.0.15' Driver info: driver.version: unknown remote stacktrace:

Could not open firefox browser. Client error message: Summary: UnknownError Detail: An unknown server-side error occurred while processing the command. Further Details: run errorDetails method Check server log for further details.

To fix this, the easiest way is to uninstall the dumpster fire snap version and install the apt version (following this https://www.omgubuntu.co.uk/2022/04/how-to-install-firefox-deb-apt-ubuntu-22-04):

sudo snap remove firefox
sudo add-apt-repository ppa:mozillateam/ppa

echo '
Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
' | sudo tee /etc/apt/preferences.d/mozilla-firefox

echo 'Unattended-Upgrade::Allowed-Origins:: "LP-PPA-mozillateam:${distro_codename}";' | sudo tee /etc/apt/apt.conf.d/51unattended-upgrades-firefox

sudo apt install firefox

After re-installing using the apt version above, RSelenium can be launched as normal in R:

port <- 4567
system(paste0("sudo kill -9 $(lsof -t -i:",port," -sTCP:LISTEN)"))

rD <- rsDriver(browser="firefox") ##works
nbarsch commented 1 year ago

I now get the error: Error in wdman::selenium(port = port, verbose = verbose, version = version, : Selenium server couldn't be started

This happened with a firefox update. Any suggestions?

BerndGit commented 1 year ago

I now also get the error: "Selenium server couldn't be started" It used to work some days ago.

To reproduce you can use my (almost minimal) dockerfile. Tested with Docker version 20.10.16, build 20.10.16-0ubuntu1

Hope this helps for debugging. Feedback for optimization of dockerfile also welcome.

Greetings, BerndGit

Docker_RSelenium.zip

nbarsch commented 1 year ago

264 See solution here that works (my response)

BerndGit commented 1 year ago

Hi nbarsch!

264 did also solve my issues.

Thanks!