- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to run Selenium tests on Chrome Browser using?
We can run Selenium tests on Chrome browser with the help of the chromedriver.exe executable file. First, we have to download the chromedriver.exe file from the following link − https://sites.google.com/a/chromium.org/chromedriver/downloads
We have to click on the link which matches with the Chrome browser in our system. Next, choose the link based operating system (Windows, Linux or Mac) we are presently using.
Once the download has completed, a zip file gets created. We have to extract the zip file and store the chromedriver.exe file in a desired location. Then, we have to configure the path of the chromedriver.exe file using the System.setProperty method along with creating an object of the ChromeDriver class.
Example
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.Capabilities; import org.openqa.selenium.remote.RemoteWebDriver; public class ChromeBrwLaunch{ public static void main(String[] args) { //configure chromedriver.exe path System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); //object of ChromeDriver WebDriver driver = new ChromeDriver(); //launch URL driver.get("https://www.tutorialspoint.com/index.htm"); // get browser name Capabilities cap = ((RemoteWebDriver) driver).getCapabilities(); System.out.println("Browser: " + cap.getBrowserName()); driver.close(); } }
Output
Advertisements