Install Selenium Webdrive on an Ubuntu Cloud Server
Every web developer knows the problem: Code is interpreted differently in every browser. With Selenium, the code can be tested automatically for different browsers.
The advantages are obvious: It is not necessary to install a lot of different browsers and not to repeat the same process over and over again. This can be automated with Selenium.
In this tutorial I show you how to create your own selenium server. As a base I take an Ubuntu Server 16.04 LTS. With gridscale, you can create your own Ubuntu server within seconds. This is immediately available online and will be billed minutes – ideal for testing!
If you are new to gridscale, please read our [How-To-Gridscale article]. Many of the most common questions are answered directly here.
Prepare the server
As before every installation you should bring your server up to date. For Debian-based distributions, this is easy to do with the following command:
apt -y update; apt -y upgrade; apt -y dist-upgrade
Like so many Selenium based on Java. Therefore, a Java engine of your choice must be installed. For the sake of simplicity I take OpenJDK; it is already included in the standard repository and is also recommended by the selenium developers. Besides, Selinum still needs a few libs. Use the following command to install everything:
apt-get install -y openjdk-8-jre-headless xvfb libxi6 libgconf-2-4 zip
In order for Selenium to simulate the various browsers, their engines and drivers are still needed. As an example, I show you how to install Chrome. The other browsers are installed similarly.
Download the Chrome.deb first:
wget -N https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -P ~/
It is then installed:
dpkg -i --force-depends ~/google-chrome-stable_current_amd64.deb apt-get -f install -y dpkg -i --force-depends ~/google-chrome-stable_current_amd64.deb
Then you need the ChromeDriver:
wget -N https://chromedriver.storage.googleapis.com/2.9/chromedriver_linux64.zip -P ~/
Unpack the ZIP file with Unzip:
unzip ~/chromedriver_linux64.zip -d ~/
After unpacking, the package is no longer needed. Delete it with the following command:
Following move the driver to the correct directory and authorize the system to run the file:
mv -f ~/chromedriver /usr/local/share/ chmod +x /usr/local/share/chromedriver
Then a symlink is needed:
ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
After all preparations have been successfully completed, you can now install Selenium. Download the latest version:
wget -N http://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar -P ~/
Afterwards move the JAR into the correct directory and make it executable. Here again you create a SymLink:
mv -f ~/selenium-server-standalone-3.4.0.jar /usr/local/share/ chmod +x /usr/local/share/selenium-server-standalone-3.4.0.jar ln -s /usr/local/share/selenium-server-standalone-3.4.0.jar /usr/local/bin/selenium-server-standalone-3.4.0.jar
That’s it already. Selenium is now ready. To start the service easy, you should put a simple small script. If you put it under /bin, you can start it from anywhere:
Insert the following code and save the file:
#!/usr/bin/env bash xvfb-run java -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver -jar /usr/local/bin/selenium-server-standalone-3.4.0.jar
You can do this with:
chmod +x /bin/selenium
With the command “selenium” you can now start the service from anywhere.
Then you can open the following URL in your browser to check the installation:
How to get to the Session Overview:
Setting up selenium is done quite quickly, but only with the web interface and via the console is relatively little to begin with. With a CD tool of your choice, such as Jenkins or Buddy, you can save your selenium server for automation and thus exploit the full potential.
Every web developer knows the problem: Code is interpreted differently in every browser. With Selenium, the code can be tested automatically for different browsers. The advantages are obvious: It is not necessary to install a lot of different browsers and not to repeat the same process over and over again. This can be automated with […]
Thank you for your feedback!
We will get back to you as soon as the article is finished.