How to launch Chrome browser using WebDriver?

Best Selenium with Java Training Institute in Hyderabad

Are you looking for the best Selenium with Java training institute in Hyderabad? Quality Thought stands out as a top-rated training institute offering industry-recognized Selenium with Java courses, tailored for graduates, postgraduates, professionals with education gaps, and those seeking job domain changes. With hands-on live internship programs guided by real-time industry experts, QualityThought ensures that every learner becomes job-ready with practical knowledge and real-world experience.

To launch Google Chrome browser using Selenium WebDriver, you’ll need:

  • Selenium WebDriver installed

  • Chrome browser installed

  • ChromeDriver (a small executable that bridges Selenium and Chrome)

✅ Steps (Java Example)

import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class LaunchChrome { public static void main(String[] args) { // 1. Set the path to chromedriver.exe (if not in system PATH) System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe"); // 2. Create a ChromeDriver instance WebDriver driver = new ChromeDriver(); // 3. Open a website driver.get("https://www.google.com"); // 4. Maximize browser window driver.manage().window().maximize(); // 5. Close the browser driver.quit(); } }

✅ Steps (Python Example)

from selenium import webdriver # 1. Create Chrome driver instance driver = webdriver.Chrome() # 2. Open a website driver.get("https://www.google.com") # 3. Maximize browser window driver.maximize_window() # 4. Close the browser driver.quit()

⚡ Notes

  • In latest Selenium 4.x, you usually don’t need to manually set ChromeDriver path if it’s in your system PATH. Selenium can auto-manage drivers using the webdriver-manager library.

  • Example in Python with webdriver-manager:

from selenium import webdriver from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())) driver.get("https://www.google.com")

Comments

Popular posts from this blog

Can I learn Selenium without knowing Java?

Is Selenium with Java in demand in Hyderabad?

What are the components of Selenium?