Open a URL

get and navigate().to

WebDriver driver = new ChromeDriver();
driver.get("https://shopease.example.com");               // waits until the page load event
driver.navigate().to("https://shopease.example.com/cart"); // same thing, keeps history for back/forward
  • get() waits for the page to finish loading (document ready state "complete") before the next line runs.
  • Always use the full URL with https://. driver.get("shopease.example.com") fails with InvalidArgumentException: invalid argument.

WebDriver Is an Interface

WebDriver is an interface; ChromeDriver, FirefoxDriver, EdgeDriver are classes that implement it. Declaring the variable as WebDriver lets you switch browsers by changing one line.

WebDriver (interface)
                |
        RemoteWebDriver (class)
        /       |        \
 ChromeDriver FirefoxDriver EdgeDriver ...