python-3.x - 错误 : no DISPLAY environment variable specified

标签 python-3.x selenium selenium-webdriver selenium-grid selenium-firefoxdriver

我已经设置了一个 Selenium Grid,在 Ubuntu Server 中设置了一个 Hub,在 Ubuntu Desktop 中设置了一个 Node。在 Node 机器上安装 Geckodriver 和 Firefox。并使用以下python代码。

from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FirefoxOptions

options = webdriver.FirefoxOptions()
driver = webdriver.Remote(
    command_executor='http://192.168.56.7:4444/wd/hub',
    options=options
)
但出现错误 错误:未指定 DISPLAY 环境变量 在 Node 机器上。
添加后工作正常
options.add_argument('--headless')
不想在 headless 模式下运行它。
提前感谢大家。

最佳答案

只需尝试设置环境变量 DISPLAY请。
您的问题与 Selenium Error: no display specified 有点重复

关于python-3.x - 错误 : no DISPLAY environment variable specified,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63592708/

相关文章:

python - 转换时忽略字符

java - 如果特定场景出现在 webdriver 中,如何运行它

python - Selenium 无法打开指定的 URL 并显示数据 :,

php - 无法使用PHPunit Selenium执行javascript

excel - 我想确定以黄色突出显示的按钮的正确代码

python - 如何在Python中将一个文件复制到另一个变量

python-3.x - 如果条件,则返回语句在 python 中不起作用

python - 我怎样才能修复这个汉诺塔程序以获得我想要的输出?

当我们不关心输出时,Python 内置习惯用法将函数应用于可迭代对象的每个元素

r - 如何使用 xpath 检查某个对象在网页中是否可见?