Getting GDK_BACKEND does not match available displays error in debian(获取 GDK_BACKEND 与 debian 中的可用显示错误不匹配)
问题描述
实际上,我正在尝试通过 selenium 在远程 debian 服务器中运行无头浏览器.我在服务器中安装了 firefox 46.0.1,我使用的是 selenium 2.53.1 版本.
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
我在我的代码中实例化了 firefox 驱动程序,如下所示:
I have instantiated firefox driver in my code like this:
saDriver = new FirefoxDriver();
谁能帮忙?
推荐答案
我对Java不熟悉.但是在 Python 中,这个问题可以通过以下方法解决,这可能会对您有所帮助
I am not familiar with Java. However in Python this issue can be solved by the following method, this may help you
如果显示错误:GDK_BACKEND 与可用显示器不匹配,则安装 pyvirtualdisplay:
pip install pyvirtualdisplay selenium
你可能也需要 xvfb:
You might need xvfb too:
sudo apt-get install xvfb
然后尝试添加此代码:
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
完整示例:
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()
这篇关于获取 GDK_BACKEND 与 debian 中的可用显示错误不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:获取 GDK_BACKEND 与 debian 中的可用显示错误不匹配


基础教程推荐
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01