0

I have started a hub and a node on the same machine using the following commands:

xvfb-run -a java -Dwebdriver.chrome.driver=/usr/bin/chromedriver -jar selenium-server-standalone.jar -role hub

xvfb-run -a java -Dwebdriver.chrome.driver=/usr/bin/chromedriver -jar selenium-server-standalone.jar -port 7777 -role node -hub http://192.168.111.253:4444/grid/register -browser browserName="chrome",version=ANY,platform=LINUX,maxInstances=5

I am trying to instantiate a browser windows using the following code:

options = webdriver.ChromeOptions()
options.add_argument("no-sandbox")
options.add_argument("--disable-gpu")
options.add_argument("--window-size=800,600")
options.add_argument("--disable-dev-shm-usage")
browser = webdriver.Remote(
    command_executor=f"http://192.168.111.253:4444/wd/hub",
    options=options
)

browser.get(r"https://www.google.com")

The page is getting fetched successfully and I can see the HTML code of the page using browser.page_source but the Chrome window doesn't open on the node. I haven't specified the headless option at all. I am using version 95 of Chrome and Chromedriver.

Please note that I am running the code on a jupyter notebook hosted on the same machine which acts as the selenium server and node. I am accessing the notebook from another computer on the same LAN.

Any help would be appreciated. Thank you.

  • You are using virtual frame buffer (aka virtual screen). How do you know the window is not appearing in that virtual screen? – Alexey R. Nov 03 '21 at 11:50
  • @AlexeyR. In the options provided, I haven't mentioned anything like that. I am a total beginner in Selenium. Could you please elaborate? If that's the reason, what can we do to see an actual window? – Nelwin Jacob Nov 03 '21 at 11:56

1 Answers1

0

Since UI implies rendering to some graphics device you have to have a screen in order to run UI applications.Virtual frame buffer is a kind of virtual screen that is normally used on the hosts having no screens plugged.

So unless you are in mentioned circumstances you shouldn't use xvfb-run, but run the nodes in a normal way that implies rendering to your local display.

If you still want to use virtual screen you can try this solution to view what is happening there: https://stackoverflow.com/a/28426615/8343843

P.S. - I would recommend to use docker Selenium images instead of running browsers in xvfb.

Alexey R.
  • 8,057
  • 2
  • 11
  • 27