Satish's answer is correct but in more layman's terms, ChromeDriver
is specifically and only a driver for Chrome. WebDriver
is a more generic driver that can be used for many different browsers... IE, Chrome, FF, etc.
If you only cared about Chrome, you might create a driver using
ChromeDriver driver = new ChromeDriver();
If you want to create a function that returns a driver for a specified browser, you could do something like the below.
public static WebDriver startDriver(Browsers browserType)
{
switch (browserType)
{
case FIREFOX:
...
return new FirefoxDriver();
case CHROME:
...
return new ChromeDriver();
case IE32:
...
return new InternetExplorerDriver();
case IE64:
...
return new InternetExplorerDriver();
default:
throw new InvalidParameterException("Unknown browser type");
}
}
public enum Browsers
{
CHROME, FIREFOX, IE32, IE64;
}
... and then call it like...
WebDriver driver = startDriver(Browsers.FIREFOX);
driver.get("http://www.google.com");
and depending on what browser you specify, that browser will be launched and navigate to google.com.