Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting GDK_BACKEND does not match available displays error in debian

Actually i am trying to run a headless browser in remote debian server through selenium. I have firefox 46.0.1 installed in the server and i am using selenium 2.53.1 version.

Whenever i tried to run a given test i got the following error.

org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: 
Error: GDK_BACKEND does not match available displays

I have instantiated firefox driver in my code like this:

saDriver = new FirefoxDriver();

can anyone help?

like image 256
tempEngineer Avatar asked Nov 24 '16 14:11

tempEngineer


Video Answer


1 Answers

I am not familiar with Java. However in Python this issue can be solved by the following method, this may help you

If it says Error: GDK_BACKEND does not match available displays then install pyvirtualdisplay:

pip install pyvirtualdisplay selenium

You might need xvfb too:

sudo apt-get install xvfb

Then try adding this code:

from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()

Full example:

from pyvirtualdisplay import Display
from selenium import webdriver

display = Display(visible=0, size=(800, 600))
display.start()

browser = webdriver.Firefox()
browser.get('http://www.python.org')

browser.close()
display.stop()
like image 120
Basil Jose Avatar answered Sep 21 '22 09:09

Basil Jose