Read This: Setup Selenium with ChromeDriver on Ubuntu
Step 1 – Prerequisites
Execute the following commands to install required packages on your system. Here Xvfb (X virtual framebuffer) is an in-memory display server for a UNIX-like operating system (e.g., Linux). It implements the X11 display server protocol without any display. This is helpful for CLI applications like CI service. Also, install Java on your system. Use the below command to install the latest available java version.
Step 2 – Install Firefox with Driver
Firefox is available under default apt repositories. You can simply install it by running the following command from the command prompt. Also, download the geckodriver for the firefox.
Step 3 – Download Selenium Server Jar
The Selenium Server is required to run Remote Selenium WebDrivers. You need to download the Selenium standalone server jar file using the below commands or visit here to find the latest version of Jar file. Also download the testng-6.5.1.jar file to your system.
Step 4 – Start Selenium Server
Your server setup is ready. Start the standalone selenium server using Xvfb utility. Run Selenium Server Your Selenium server is now running with firefox. Use this server to run your test cases written in Selenium using the Firefox web browser.
Step 5 – Sample Java Program (Optional)
This is an optional step. It describes running a single test case using Selenium standalone server and FirefoxDriver. This Java program will open a specified website URL and check if defined string presents on the webpage or not. Create a Java program by editing a file in a text editor. Add the below content to file.
You can change the URL “https://google.com” with any other URL of your choice, Then also change the search string like “I’m Feeling Lucky” used in the above Java program. Save your java program and execute it. First, you need to set the Java CLASSPATH environment variable including the selenium-server-standalone-3.141.59.jar and testng-6.5.1.jar. Then compile the java program and run it. Now, compile your Java program and run it. If the defined search string found, You will get message “Pass” and if string not found on the webpage, you will get the “Fail” message on the screen.