0

I have a something like:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

class Gecko { 


...
FirefoxBinary ffB = new FirefoxBinary();
ffB.setEnvironmentProperty("DISPLAY", ":10");
...
options.setBinary(ffB);
WebDriver driver = new FirefoxDriver(options);

Then I start a virtual frame buffer with:

Xvfb :10 -screen 0 1024x768x24 &

But when I run with Selenium:

java -cp .:selenium-server-standalone-3.5.0.jar Gecko

the following problem shows:

1508364524466 geckodriver::marionette INFO Starting browser /usr/bin/firefox with args ["-marionette"]
Error: GDK_BACKEND does not match available displays
Exception in thread "main" org.openqa.selenium.WebDriverException: connection refused

Which could be a possible cause? User permission? Firewall? The current box doesn't have any desktop environment installed.

Thomas Fritsch
  • 9,639
  • 33
  • 37
  • 49
y.z
  • 11
  • 6
  • [Click here](https://stackoverflow.com/questions/40789338/getting-gdk-backend-does-not-match-available-displays-error-in-debian) Perhaps you can take help from this link. – AutomationEngineer Oct 19 '17 at 07:20

1 Answers1

0

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()
  • Thanks, but that doesn't solve my problem. It helps me in the sense that I can use selenium with python + pyvirtualdisplay but I'm trying to use it with java + xvfb. I've said that I do: Xvfb :10 -screen 0 1024x768x24 & in java... ffB.setEnvironmentProperty("DISPLAY", ":10"); but when I run Gecko it shows in output: 1508525094630 geckodriver::marionette INFO Starting browser /usr/bin/firefox with args ["-marionette"] Error: GDK_BACKEND does not match available displays when running line: WebDriver driver = new FirefoxDriver(options); – y.z Oct 20 '17 at 18:49