- Trending Categories
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 do I open Chrome in selenium WebDriver?
We can open Chrome browser in Selenium webdriver. We can launch Chrome by instantiating an object of the ChromeDriver class with the help of the below statement.
WebDriver driver = new ChromeDriver();
Next we have to download the chromedriver and configure it to our project by following the below step by step processes −
Navigate to the link − https://www.selenium.dev/downloads/ and below the Browser, there is a Chrome section available. Click on the documentation link just below that.
As per version of the Chrome browser in the system, we have to select the download link. The next page shall be navigated where links to chrome drivers compatible with various operating systems are present.
After selecting the chrome driver as per the system configuration for download, a zip file gets created. We need to extract that and save the chromedriver.exe file at any location.
Let us discuss how to configure chromedriver with System properties within the Selenium code −
Add the System.setProperty method in the code which takes the browser type and the path of the chromedriver executable path as parameters.
System.setProperty("webdriver.chrome.driver","<chromedriver path>");
Example
Code Implementation
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class ChromeBrw{ public static void main(String[] args) { // creating object of ChromeDriver WebDriver driver = new ChromeDriver(); // to configure the path of the chromedriver.exe System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); String url = "https://www.tutorialspoint.com/index.htm"; driver.get(url); } }
- Related Articles
- How to open a link in new tab of chrome browser using Selenium WebDriver?
- How do I resolve the ElementNotInteractableException in Selenium WebDriver?
- Running Selenium WebDriver python bindings in chrome.
- How to run Selenium WebDriver test cases in Chrome?
- How does Selenium Webdriver handle SSL certificate in Chrome?
- How to open chrome default profile with selenium?
- How to mute all sounds in chrome webdriver with selenium?
- How do I set the Selenium webdriver get timeout?
- How to programmatically configure Chrome extension through Selenium WebDriver?
- How do I get current URL in Selenium Webdriver 2 Python?
- How do I set browser width and height in Selenium WebDriver?
- How to use chrome webdriver in Selenium to download files in Python?
- How do I pass options to the Selenium Chrome driver using Python?
- How to open a new tab using Selenium WebDriver?
- How to open a link in new tab using Selenium WebDriver?
