I recently installed Python 2.7, Robot Framework and the Selenium Library (I still don't know if I succeeded though...) on a Red Hat Server to run some test on a web application.
So I tried a simple test case using Robot Framework to see if Selenium Library is functional, just to Open a web page, nothing more...
Selenium Server is up and running according to the result of ps, and Firefox binaries are in the PATH...
Running the test case from the Robot Framework (with the pybot testcasename.tsv) I get an exception:
ERROR: Problem capturing a screenshot to string: java.awt.AWTException: headless environment
So, what is the headless environment? Does anyone have an idea if there is something else that needs to be installed or to be configured as well?
Yes, Selenium supports headless testing. In older versions of Selenium, we used the HTMLUnitDriver mainly, a headless driver providing a Non-GUI implementation of Selenium WebDriver.
You can run Google Chrome in headless mode simply by setting the headless property of the chromeOptions object to True. Or, you can use the add_argument() method of the chromeOptions object to add the –headless command-line argument to run Google Chrome in headless mode using the Selenium Chrome web driver.
What is Headless testing? Headless testing is simply running your Selenium tests using a headless browser. It operates as your typical browser would, but without a user interface, making it excellent for automated testing.
Headless, in this context, basically means that the computing device has no monitor or peripherals, such as a keyboard and mouse. Depending on the type of device they run in, headless systems may largely run autonomously or be remotely controlled. Servers in large data center environments are often headless.
We can use xvfb to create a headless environment for selenium (for example, to run over SSH).
Start xvfb
with the following options:
$ Xvfb :89 -ac -noreset
(where :89
is the virtual "display" created).
Then, set the DISPLAY
variable to be this virtual display:
$ export DISPLAY=:89
At this point, we can run the selenium server as desired. Examples follow.
Run the server Java archive:
$ java -jar selenium-server.jar
In Python:
from selenium import webdriver
driver = webdriver.Firefox()
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With