Skip to content

firefox headless - Error: no DISPLAY environment variable specified #701

@jbnjohnathan

Description

@jbnjohnathan

When running the command pytest app/gui_tests/selenium/ --browser=firefox --headless -v -s in Docker I got the error from selenium: Exception: Message: invalid argument: can't kill an exited process

I tested to run firefox manually with firefox -headless and it seemed to work fine as it output *** You are running in headless mode.
So I checked the geckodriver.log for clues

I found this log entry

1600603147457   mozrunner::runner       INFO    Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofileLUeNt1"
Error: no DISPLAY environment variable specified

What struck me was that it wasn't using -headless as an argument to Firefox, which would explain why it would complain about the DISPLAY env not being set.
Is this a bug since I used the parameter --headless for selenium (and it seem to be default set as well). Or am I misunderstanding something?

Also as a side note. It would have been nice if the error from seleniumbase would have been nicer and included the Error: no DISPLAY environment variable specified message directly, instead of having to check the geckodriver.log

The annoying part is that it works perfectly fine in a Github Action container, but not when I create my own Dockerfile. Not sure what magic Github is doing when they create their own.
FYI When I run it in Github Actions the geckodriver.log file has this content instead

1600627799085	mozrunner::runner	INFO	Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile7Vv40c"
console.error: SearchCache: "_readCacheFile: Error reading cache file:" (new Error("", "(unknown module)"))
1600627814960	Marionette	INFO	Listening on port 35239
1600627815019	Marionette	WARN	TLS certificate errors will be ignored for this session
JavaScript error: resource://gre/modules/URIFixup.jsm, line 271: NS_ERROR_FAILURE: Should pass a non-null uri
1600627819117	Marionette	INFO	Stopped listening on port 35239

In docker:
seleniumbase==1.42.5 (tried upgrading to 1.49.16 but same issue)
pytest==5.4.3
python 3.8.2
firefox 80.0.1
Ubuntu 20.04
geckodriver = 2.44

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions