我已经设置了一个 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/