Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Selenium headless without using xvfb

I'm trying to run Selenium headless (without the browser appearing). Other questions have pointed to xvfb as the tool to do this. However, it appears highly unstable, crashing all the time, so I'm looking for another alternative.

Is there a non-xvfb way of running Selenium headless?

like image 231
Paul Biggar Avatar asked Dec 27 '09 16:12

Paul Biggar


People also ask

How do I run Selenium in headless mode?

ChromeOptions options = new ChromeOptions() options. addArgument("headless"); ChromeDriver driver = new ChromeDriver(options); In the above code, the browser is instructed to run in the headless mode using the addArgument() method of the ChromeOptions class provided by the Selenium WebDriver.

Why is XVFB used?

Xvfb (short for X virtual framebuffer) is an in-memory display server for UNIX-like operating system (e.g., Linux). It enables you to run graphical applications without a display (e.g., browser tests on a CI server) while also having the ability to take screenshots.

Is running Selenium headless faster?

Improved speed and performance Selenium tests can take a while to complete, due to elements on a page that the browser needs to load. Headless testing gets rid of this load time, allowing you to cut your testing times significantly. In our tests with headless testing, we've seen a 30% reduction of test execution times.

How do I run a test in headless mode?

Test Studio currently supports the headless mode for Chrome and Edge Chromium browsers. You can execute any existing test in your automation project in headless mode by selecting that type of browser.


1 Answers

I don't think you'll be able to run a browser without running an X server.

If you don't like Xvfb, then as Pascal said, your best bet might be to run a VNC server -- I personally like Xtightvnc. This means you're running a (headless) X server that you can VNC into at any time, in case things go wrong and you want to look at it. I always have a VNC server running, and I'm running my tests with the $DISPLAY environment variable pointing to that server.

(Someone's downvoted me, so maybe I should clarify: X11 VNC servers like Xtightvnc are not the same as the usual VNC servers on Windows or OS X, which would simply share your existing screen on the network. Do not confuse. ;-) )

like image 69
Jo Liss Avatar answered Oct 05 '22 21:10

Jo Liss