Error: no DISPLAY environment variable specified

Viewed 14979

I have set up one Selenium Grid with one Hub in Ubuntu Server and one Node in Ubuntu Desktop. Installed Geckodriver and Firefox on the Node machine. And using the following python code.

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
)

But getting error Error: no DISPLAY environment variable specified on the Node machine.

Working exactly fine after adding

options.add_argument('--headless')

Don't want to run it in headless mode.

Thanks to all in advance.

2 Answers

Check out the link provided by @peter-quan. And you will face this issue if you are running the node connection from SSH.

In addition to this, I am adding the commands that helped me to solve the issue.

sudo apt-get install xvfb
touch ~/.Xauthority
xauth generate :0 . trusted
xauth add ${HOST}:0 . $(xxd -l 16 -p /dev/urandom)
xauth list
export DISPLAY=:0
java -jar selenium-server-standalone-3.141.59.jar -role node -hub http://[HUB-IP]:4444/grid/register/
Related