Google News
logo
Selenium - Interview Questions
Write a code snippet to launch Chrome browser in WebDriver.
public class ChromeBrowserLaunchDemo {  
  
public static void main(String[] args) {  
  
//Creating a driver object referencing WebDriver interface  
WebDriver driver;  
  
//Setting the webdriver.chrome.driver property to its executable's location  
System.setProperty("webdriver.chrome.driver", "/lib/chromeDriver/chromedriver.exe");  
      
//Instantiating driver object  
driver = newChromeDriver();  
  
//Using get() method to open a webpage  
driver.get("http://freetimelearning.com");  
  
//Closing the browser  
driver.quit();  
  
    }  
}  
Advertisement