I'm using Codeception on various cloud platforms like Amazon AWS and Cloud 9. Neither of which has a GUI by default. My question is, can you run Selenium on this type of system? Or do I need to somehow get a GUI?
We can run Selenium (Firefox) webdriver without a GUI. This means that the execution has to be kicked in headless mode. The headless execution is popular now since it results in less consumption of resources.
Selenium is an open-source tool or framework that helps testers or developers to run automated tests on web-browser. You can run selenium on Windows,macOS, and Linux.
Conclusion: Selenium drives the testing using the driver object that identifies the elements on screen using id, xpath etc. Through these functions, we can identify GUI objects of web applications through selenium web driver.
Installing Selenium Tools on LinuxJava must be installed on your computer. Install Oracle Java 8 or OpenJDK with the command below. Step 2: Install Google Chrome. Using the commands shown below, install the most recent Google Chrome package on your PC.
Selenium is only a library, and as such it does not particularly care if you are running it on a system that is equipped with a GUI. What you are probably asking is: If I use Selenium to open a browser, is that browser going to work on a system with no GUI. The answer to this is: it depends!
There are headless browsers: browsers that also do not have a GUI component. HtmlUnit is packaged with Selenium. Another popular browser is PhantomJS, which has third-party Selenium bindings library called GhostDriver. Personally I would avoid both of these! HtmlUnit uses a JavaScript engine that none of the current desktop browsers support, and as such the tests are not very reliable. GhostDriver has not been maintained for 2 years, and as such also makes for unreliable results. PahntomJS is definitely an option, as it uses WebKit - the engine that is in Safari and Chrome browsers, but you would have to write your own API.
Most systems will allow you to have a virtual GUI. You mentioned Ubuntu, which is a Debian derivative. There are several tutorials on the Net that tell you how to install Xvfb, most of which are incomplete or wrong. On a Debian you install a headless browser like this:
apt-get install xvfb
wget
on your server to grab the package./usr/local/lib
, and then create a soft link from /usr/local/bin
to the binary that launches the browser.xvfb-run firefox
. This may produce some errors, which you have to fix. In my case, I was missing the library libdbus-glib-1-2
which I could install just using apt-get.Xvfb :99 &
. See the docs for additional information.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