Why we write WebDriver driver = new ChromeDriver(); in Selenium Web Driver?

System.setProperty(“webdriver.chrome.driver”,”<ChromeDriver_Path>/chromedriver”);
WebDriver driver = new ChromeDriver();
WebDriver driver = new WebDriver();
OR
ChromeDriver driver = new ChromeDriver();
ChromeDriver driver = new ChromeDriver();
driver.get("https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/WebDriver.html");
FirefoxDriver driver_1= new FirefoxDriver();
WebDriver driver = new ChromeDriver();
WebDriver driver = new FirefoxDriver();
WebDriver driver;
//Use driver instance to execute test on Chrome browser
System.setProperty(“webdriver.chrome.driver”,”<ChromeDriver_Path>/chromedriver”);
driver = new ChromeDriver();
//test code
driver.quit()
//Use same driver instance to execute test on Firefox browser
System.setProperty("webdriver.gecko.driver", "C:\\Drivers\\geckodriver.exe");
driver = new FirefoxDriver();
driver.quit()
Compile Time Error
WebDriver driver;
//Use driver instance to execute test on Chrome browser
System.setProperty(“webdriver.chrome.driver”,”<ChromeDriver_Path>/chromedriver”);
driver = new ChromeDriver();
//test code
driver.launchApp("")
;driver.quit()
WebDriver driver;
System.setProperty(“webdriver.chrome.driver”,”<ChromeDriver_Path>/chromedriver”);
driver = new ChromeDriver();
((ChromeDriver) driver).launchApp("");
driver.quit();

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store