Testing / Selenium Interview questions
How do you launch a browser using Selenium WebDriver?
Launching a browser means instantiating the driver class for that browser, which starts the matching driver executable and opens a fresh browser session.
WebDriver driver = new ChromeDriver(); driver.get("https://example.com"); // ... test steps ... driver.quit();
Browser-specific Options classes (ChromeOptions, FirefoxOptions) configure things like headless mode, window size, or custom capabilities before the session starts:
ChromeOptions options = new ChromeOptions(); options.addArguments("--headless=new"); WebDriver driver = new ChromeDriver(options);
Calling driver.quit() at the end is important - it closes every window belonging to that session and terminates the underlying driver process, which prevents orphaned browser processes from accumulating across test runs.
More Related questions...