Error when executing headless firefox through Selenium
Solution 1
Apparently this is caused because of incompatibility between Firefox 48 and Selenium(selenium extension is not signed in firefox 48, and firefox 48 only runs signed extensions). I just used chrome, as my use-case was not extremely browser-specific.
Solution 2
I solved this issue with Firefox. The steps are:
- Downgraded Firefox from 49.0 to 46.0
- Install XVFB by command
sudo apt-get install xvfb
- Run Selenium with the command
xvfb-run java8 -jar selenium-project.jar
My Selenium version is 2.53.1
and Ubuntu 14.04.
Related videos on Youtube
goluhaque
Updated on September 18, 2022Comments
-
goluhaque over 1 year
I am trying to execute headless firefox on the remote machine(running Ubuntu 16.04) through Selenium via SSH. However, this gives me a "Error: GDK_BACKEND does not match available displays" error. My host machine runs Windows. I do not want to see the graphical output. It is just being used for selenium testing.
I am using X Virtual Frame Buffer to act as a dummy driver:
Xvfb :10 -screen 0 1024x768x16 &
I also have exported the DISPLAY environment variable with the value of 10 for this specific case.
Where am I going wrong?
EDIT: When I simply run "sudo firefox" in my commandline over SSH after running xvbf, no errors are thrown. Errors are only thrown when running firefox through selenium.
More Details:-
I am calling firefox through selenium. The exact error that the selenium standalone server gives is:-
17:52:55.218 INFO - Executing: [new session: Capabilities [{browserName=firefox, platform=ANY, firefox_profile=UEsDBBQAAAAAAJuOD0nf9RXUMgAAA...}]]) 17:52:55.230 INFO - Creating a new session for Capabilities [{browserName=firefox, platform=ANY, firefox_profile=UEsDBBQAAAAAAJuOD0nf9RXUMgAAA...}] org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: Error: GDK_BACKEND does not match available displays
-
grochmal over 7 yearsApparently ubuntu does not come with
xinit
installed by default so, maybe, firefox cannot find that it should be using xorg as the backend. -
goluhaque over 7 years@grochmal I do not really know xserver in depth. Can you please explain why I need xinit?
-
goluhaque over 7 yearsApparently this is caused because of incompatibility between Firefox 48 and Selenium(selenium extension is not signed in firefox 48, and firefox 48 only runs signed extensions). I just went ahead with using chrome.
-