
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Use Selenium with Chromium Browser
We can use Selenium with Chromium browser. Prior to working with Chrome with Selenium, we should have the Java JDK, a Java IDE and Selenium webdriver configured in our system. Then, we must download the chromodriver.exe file and set it up in our project with the below steps −
Visit the link: https://chromedriver.chromium.org/downloads. There shall be links available for download for various chromedriver versions.
Select the version which is compatible with the Chrome available to our system. Click on it. As the following page is navigated, select the zip file available for download for various operating systems (Linux, windows). Choose the one which matches with your local configuration.
Once the zip file is downloaded, extract it and save the chromodriver.exe file at a location.
Now, we can set up the chromedriver by the following methods −
Via System Properties method.
Via System Properties in Environment Variables.
To set chromedriver in the System Properties, use the System.setProperty method which has the type of browser and the chromedriver.exe file location as parameters.
Also add the import org.openqa.selenium.chrome.ChromeDriver statement for importing ChromeDriver.
Example
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class ChromiumBrowser{ public static void main(String[] args) { WebDriver driver = new ChromeDriver(); // chromedriver.exe path set System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); String u = "https://www.tutorialspoint.com/index.htm"; driver.get(u); } }
To set chromedriver with the System properties in the Environment Variables follow the below steps −
Go to the Start and search for the environment.
System Properties pop−up comes up. Move to Advanced tab and then click on Environment Variables.
Environment Variables pop−up comes up. Move to System Variables and then click on Path variable. Then click on Edit.
Within the Edit environment variable pop up click on New.
The path of the chromedriver.exe file is to be added, then click on OK.
Example
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class ChromiumLaunch{ public static void main(String[] args) { WebDriver driver = new ChromeDriver(); String u = "https://www.tutorialspoint.com/index.htm"; driver.get(u); } }