Search code examples
linuxfirefoxseleniumrhelcodeception

RHEL + Codeception: invalid mit-magic-cookie-1 keyerror cannot open display :2.0


So I'm trying to run Codeception acceptance tests on a Linux server (with Selenium). I enter the command:

./codecept run acceptance

(with flags such as --env firefox-linux)

Codeception starts, pauses for a bit and then Firefox throws this error:

Invalid MIT-MAGIC-COOKIE-1 keyError: cannot open display: :2.0

I read that this was something to do with xauth stuff, so I have tried deleting and re-creating my Xauthority, EXPORT DISPLAY etc., but I still get the error.

A few things to note: RHEL 6.6, Firefox 27 (using an older version to work with Selenium)

Also I have a hunch that this might not actually be an 'X' problem, but something in the general config? Will have a look, but any suggestions are much appreciated.


Solution

  • After poking around I discovered the error was actually in Selenium. Firstly, the versions of Selenium and Firefox were incompatible, so I changed that, but then started getting a 'no display specified' error. Then I changed the Selenium build command to:

    export DISPLAY=":1" && java -jar selenium-server-standalone-2.44.0.jar
    

    This is probably only a temporary solution, but for others who are having this issue I suggest you look at your Selenium and browser config, look at your /etc/hosts and see what it says, then try and export the correct display. So for example my /etc/hosts says:

    127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
    

    I executed the above command with the export display, which started selenium, then ran codeception and it started correctly.