Is anyone here using newer versions of Firefox (48+) and Selenium for robot tests? What's your configuration to make it work and avoid "selenium.common.exceptions.WebDriverException: Message: Can't load the profile."?

Ubuntu has had a package for ~4 years now. Annoyingly as per history it has a different name than the Debian package does.

In case someone wants to try this for themselves, roll out a fresh server (like a Digital Ocean high CPU instance as they are quick enough and cheap enough for a quick spin like this).

Chrome needs to run as non-root. Otherwise you'd have to pass in all sorts of flags like turning off the sandbox and the GPU support. A lot of people out there seem to be confused over this.

Debian:

#!/bin/bash
set -e
apt update
apt build-dep -y python python-imaging python-lxml python-pyscss python-yaml
apt install -y git python-pip python-virtualenv wv pdftohtml locales-all xvfb chromedriver

useradd -m plone

cd /home/plone

su plone -c 'git clone https://github.com/plone/buildout.coredev.git'
cd buildout.coredev

su plone -c './bootstrap.sh'

su plone -c 'ROBOT_BROWSER='chrome' xvfb-run bin/alltests --all --xml'
su plone -c 'bin/alltests-at --all --xml'

Ubuntu:

#!/bin/bash
set -e
apt update
apt build-dep -y python python-imaging python-lxml python-pyscss python-yaml
apt install -y git python-pip python-virtualenv wv pdftohtml locales-all xvfb chromium-chromedriver

useradd -m plone

cd /home/plone

su plone -c 'git clone https://github.com/plone/buildout.coredev.git'
cd buildout.coredev

su plone -c './bootstrap.sh'

su plone -c 'ROBOT_BROWSER='chrome' xvfb-run bin/alltests --all --xml'
su plone -c 'bin/alltests-at --all --xml'

Do note the use of build-dep for getting the build-time dependencies of Plone. This brings in a bit of unnecessary packaging tooling as well and is thus not the minimal set, but is worth noting as a concept for the simplicity of tackling the "dependency hell" scenario of "urgh, I need to build package foo now". If the package has a compatible enough version in the distro tree, apt build-dep foo and be done with it (apt-get and aptitude also have this feature).

I've also added locales-all to the packages as your ssh session can try to bring in your machine locale and that not being available can flunk the bootstrap script. If you have a funkier locale setup on your workstation side and that gets in the way, simply do su plone -c "LC_ALL='C' ./bootstrap.sh" for that step to circumvent.

Older versions of Ubuntu might not yet have apt installed per default, so install apt or substitute with apt-get or aptitude where appropriate for your testing (but do note aptitude pulls in recommended packages per default as well while the others do not).

Likewise if desiring to use Gecko, use firefoxdriver instead of chromedriver and ROBOT_BROWSER='firefox' instead of ROBOT_BROWSER='chrome' (or leave it undefined as Firefox is the default).

This should also work with the distro packages on Travis. @tisto, wanna give that a try as well?

As the packages in question are volatile, if one wants to pin exact versions of something for repeatability, apt has a syntax of package=versionname for this. On Debian 9, for example, one could do apt install chromium-driver=62.0.3202.89-1~deb9u1 chromium=62.0.3202.89-1~deb9u1 while the current packages are based on Chrome 64 at the moment.

Pulling it in manually does give you more control over the exact version range available, as you can also pull in versions not available in the distro tree, though.

Download the latest version of the Mozilla geckodriver and install it, then put these version pins in your project.

# Works with Firefox 55 & Firefox 52
robotframework = 3.0.2
robotframework-debuglibrary = 1.0.1
plone.app.robotframework = 1.1.1
robotframework-selenium2library = 1.8.0
robotframework-selenium2screenshots = 0.7.2
robotsuite = 2.0.0
selenium = 3.5.0
prompt-toolkit = 1.0.15
wcwidth = 0.1.7

This works for me on Plone 5.0.8...

2 Likes

Is it really so that headless Firefox takes screenshots properly, but only if you run headless with X server?

Haven't tested it with Firefox but I can confirm that Chrome needs a running X server to take screenshots.

today I was able to run collective.cover tests successfully with @gotcha's KGS using Mozilla Firefox 60.0.2 in headless mode and geckodriver 0.20.1:

2 Likes

Also a practical tip discovered this week in the Saltlabs sprint in Halle is to increase the screen size of the X11 display. Robot does not seem to click on elements not present in the viewport. We fear this has been the root cause of the flakiness so far.

xvfb-run -a --server-args='-screen 0 1920x1200x24'

Additionally if you are getting a run stuck locally due to that, it can continue by opening the inspector as it can find the element there, click it, and have the viewport scroll to the real one, allowing the execution to continue. Thank you @jaroel for that one, that is one of my personal favourite top ten clunks of all time now.

4 Likes

Yeah, that was fun :smiley:

How this can be added to docs? This is really helpful. Thaks for sharing.

@hvelarde @rodfersou

There's full compatibility table for geckodriver/selenium/firefox in Supported platforms — Firefox Source Docs documentation