Himadri Ganguly
Himadri Ganguly

Reputation: 743

Error: no DISPLAY environment variable specified

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.

Upvotes: 4

Views: 24064

Answers (2)

Himadri Ganguly
Himadri Ganguly

Reputation: 743

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/

Upvotes: 2

Peter Quan
Peter Quan

Reputation: 808

Just try to set environment variable DISPLAY please.

Your question is a bit duplicated with Selenium Error: no display specified

Upvotes: 3

Related Questions