Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

node-firefox with --headless rather than XVFB #567

Closed
graingert opened this issue Sep 14, 2017 · 12 comments · Fixed by #796
Closed

node-firefox with --headless rather than XVFB #567

graingert opened this issue Sep 14, 2017 · 12 comments · Fixed by #796

Comments

@graingert
Copy link
Contributor

Firefox is headless as well as chrome. No need for XVFB anywhere at all now

@danielmenezesbr
Copy link

@AndreSteenbergen
Copy link

Actually ... there is a big difference, in headless you can't enable extensions in chrome. So the experience in headless is not exactly the same as with a "real" browser. That's actually what selenium is about I think, be as close to a real experience as possible for UI automation.

@graingert
Copy link
Contributor Author

Pretty sure you can in Firefox, so the point's moot

@mykmelez
Copy link

mykmelez commented Nov 6, 2017

That's actually what selenium is about I think, be as close to a real experience as possible for UI automation.

That's a goal for the headless feature in Firefox as well: to run the full Firefox browser in a way that is as similar as possible to a user's experience of headed Firefox.

Any differences between headed and headless Firefox (besides headlessness, of course) are thus considered to be Firefox bugs and should be reported via this bug reporting form. For example, see bug 1375585 - Support WebGL in headless mode. Here's the full list of open bugs.

(Note: I'm the product manager for headless browsing in Firefox.)

@adiohana
Copy link

adiohana commented Feb 5, 2018

Are you saying we are able to run Firefox without Xvfb in headless mode?
I'm getting this error:
Error: GDK_BACKEND does not match available displays

@graingert
Copy link
Contributor Author

@adiohana yes but you need to configure it correctly

@adiohana
Copy link

adiohana commented Feb 5, 2018

@graingert

any documentation to follow for this?

@jlehtimaki
Copy link

@graingert could you please share how to get it working with headless?

@SavePointSam
Copy link

@graingert I've hit the same wall where running -headless still throws:

Error: GDK_BACKEND does not match available displays

What else needs to be done to configure headless properly?

@SavePointSam
Copy link

My solution was upgrading to Firefox 59. I was using Firefox 52 which didn't have proper support for -headless. It appears the functionality didn't get properly added until Firefox 55.

diemol added a commit that referenced this issue Oct 3, 2018
wants to run Chrome and Firefox in headless mode and thinks that Xvfb
uses too many resources. Fixes #429 and fixes #567.
@diemol
Copy link
Member

diemol commented Oct 3, 2018

Hi all,

We just made a change in the images and introduces the env var START_XVFB, you can set it to false(or anything different to true when starting the container, and then Xvfb won't be started.

docker network create grid
docker run -d -p 4444:4444 --net grid --name selenium-hub selenium/hub
docker run -d --net grid -e HUB_HOST=selenium-hub -e START_XVFB=false -v /dev/shm:/dev/shm selenium/node-chrome
docker run -d --net grid -e HUB_HOST=selenium-hub -e START_XVFB=false -v /dev/shm:/dev/shm selenium/node-firefox

If you do that, and check the running processes in the container, you'll see:

seluser@6c5028fb1dad:~$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
seluser      1  0.2  0.1  58660 18484 ?        Ss   20:30   0:00 /usr/bin/python /usr/bin/supervisord --configuration /etc/supervisord.conf
seluser     13  0.0  0.0  20988  3364 ?        S    20:30   0:00 /bin/bash /opt/bin/start-selenium-node.sh
seluser     26  5.1  1.2 7244440 129376 ?      Sl   20:30   0:03 java -jar /opt/selenium/selenium-server-standalone.jar -role node -hub http://selenium-hub:4444/grid/register -nodeConfig /opt/selenium/config.json
seluser     55  0.0  0.0  21188  3792 pts/0    Ss   20:31   0:00 bash
seluser    774  0.0  0.0  37360  3244 pts/0    R+   20:32   0:00 ps aux

So Xvfb won't run and you'll need to run tests with the headless flag set to true, e.g. in Java:

    @Test()
    public void firefoxTest() throws Exception {
        FirefoxOptions firefoxOptions = new FirefoxOptions();
        firefoxOptions.setHeadless(true);
        WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), firefoxOptions);
        driver.get("http://the-internet.herokuapp.com");
        Assert.assertEquals(driver.getTitle(), "The Internet");
        driver.quit();
    }

and for Chrome:

    @Test()
    public void chromeProfile() throws Exception {
        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.setHeadless(true);
        WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), chromeOptions);
        driver.get("http://the-internet.herokuapp.com");
        Assert.assertEquals(driver.getTitle(), "The Internet");
        driver.quit();
    }

Therefore you can now run the images without Xvfb. I will comment again when the images with this change are released and pushed to Docker Hub.

diemol added a commit that referenced this issue Oct 3, 2018
…#796)

wants to run Chrome and Firefox in headless mode and thinks that Xvfb
uses too many resources. Fixes #429 and fixes #567.
@diemol
Copy link
Member

diemol commented Oct 3, 2018

@lock lock bot locked and limited conversation to collaborators Aug 14, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants