Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run Selenium scripts without having an X server running, too?

I have a python script that uses selenium RC; specifically webdriver.

I would love to have the script run as a post-commit hook, ideally through IE, Safari (if possible), Chrome & Firefox.

But I'm not sure what I'd need to do, since every time I run it on my local machine, a browser pops up.

I've heard of "saucelabs". Is it the best solution?

like image 541
Zack Burt Avatar asked Feb 09 '12 08:02

Zack Burt


People also ask

Is Selenium server needed to run Selenium WebDriver scripts?

WebDriver Architecture WebDriver uses the browsers support and capabilities to automation. Unlike Selenium RC, Selenium WebDriver doesn't essentially require Selenium Server to be started before launching the test script execution.

Does Selenium require server?

The Selenium Server is needed in order to run Remote Selenium WebDriver (Grid). To use the Selenium Server in a Grid configuration see the documentation. This is required if you want to make use of the latest and greatest features of the WebDriver InternetExplorerDriver.

Is it possible to run a Selenium test without using a real browser?

We can perform Selenium testing without a browser. This is achieved by triggering the execution in a headless mode. The headless execution can decrease the utilization of key resources and is being adopted widely.

Can we use Selenium to work with an already open browser session?

We can connect to an already open browser using Selenium webdriver. This can be done using the Capabilities and ChromeOptions classes. The Capabilities class obtains the browser capabilities with the help of the getCapabilities method.


1 Answers

Yes, you need to have X server running because Selenium requires a running browser and browsers need some kind of X server in order to run.

Fortunately there are many types of X servers and one of them is Xvfb aka X virtual framebuffer that does all the operations in memory and thus requires no screen.

Wikipedia has also some nice examples.

Also there are lots of questions here on SO for keywords headless, xvfb and selenium. Choose wisely ;)

[Edit]: Here's a nice example.

like image 96
plaes Avatar answered Oct 05 '22 03:10

plaes