This tutorial will help you to set up Selenium with ChromeDriver on Fedora systems. This tutorial also includes an example of a Java program that uses the Selenium standalone server and ChromeDriver and runs a sample test case.
This tutorial described how to set up a selenium server with a chrome driver on a Fedora system. Also, you will get a sample Java program to run a small test over selenium with a headless chrome driver.
Login to your Fedora system with Sudo privileged account. Launch a terminal and execute the following commands to install the required packages on your system.
sudo dnf install unzip wget java-11-openjdk java-11-openjdk-devel
Step 1 – Installing Google Chrome
Enable the Google chrome repository for installing latest versions. Execute the following commands, this will enable google-chrome repo on your Fedora system:
sudo dnf install fedora-workstation-repositories
sudo dnf config-manager --set-enabled google-chrome
Next install the Google chrome web browser:
sudo dnf install google-chrome-stable
Step 2 – Install ChromeDriver
You are also required to set up ChromeDriver on your system. ChromeDriver is a standalone server which implements WebDriver’s wire protocol for Chromium. The WebDriver is an open-source tool for automated testing of web apps across multiple browsers.
You can find the latest ChromeDriver on its official download page. Now execute below commands to configure ChromeDriver on your system.
sudo mv chromedriver /usr/bin/chromedriver
sudo chown root:root /usr/bin/chromedriver
sudo chmod +x /usr/bin/chromedriver
Step 3 – Download Required Jar Files
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 jar file on your system.
Your Selenium server is now running with Chrome. Use this server to run your test cases written in Selenium using the Google Chrome web browser. The next step is an optional step and doesn’t depend on Step 5.
Step 4 – Testing with Sample Java Application
This is an optional step. It describes running a single test case using the Selenium standalone server and ChromeDriver. Let’s create a Java program using the Selenium server and Chrome Driver. This Java program will open a specified website URL and check if the defined string is present on the webpage or not.
Create a Java program by editing a file in text editor.
Add the below content to the 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.jar and testng-6.8.7.jar. Then compile the java program and run it.
Then run command:
OutputStarting ChromeDriver 2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706) on port 10968 Only local connections are allowed. Feb 01, 2020 10:51:40 AM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS Pass
You will see the results below. If the defined search string is found, You will get the message “Pass” and if the string is not found on the webpage, you will get the “Fail” message on the screen.
You have successfully configured Selenium with ChromeDrive on your Fedora system. Now you can automate your test cases and run them periodically. I hope this tutorial contributes a little help to you with the automation testing. Please do not forget to share this tutorial.