Is webdriver a class or a interface?
Solution 1
WebDriver is a public interface and I do not think ChromeDriver or any other driver implement WebDriver they rather extend RemoteWebDriver which is a class.
Edit
As I have said the drivers extends RemoteWebDriver and that has the actual implementation of those method..
public void get(String url) {
execute(DriverCommand.GET, ImmutableMap.of("url", url));
}
Java source:
public interface WebDriver extends SearchContext {
// Navigation
/**
* Load a new web page in the current browser window. This is done using an HTTP GET operation,
* and the method will block until the load is complete. This will follow redirects issued either
* by the server or as a meta-redirect from within the returned HTML. Should a meta-redirect
* "rest" for any duration of time, it is best to wait until this timeout is over, since should
* the underlying page change whilst your test is executing the results of future calls against
* this interface will be against the freshly loaded page. Synonym for
* {@link org.openqa.selenium.WebDriver.Navigation#to(String)}.
*
* @param url The URL to load. It is best to use a fully qualified URL
*/
Solution 2
WebDriver is a public interface, we just define a reference variable(driver) whose type is interface. Now any object we assign to it must be a instance of a class (fireFoxDriver)that implement the interface.
Mainak Sikdar
Updated on August 19, 2022Comments
-
Mainak Sikdar over 1 year
From the Selenium docs, WebDriver is an Interface but in Eclipse the package
org.openqa.selenium
is shown as a Class in the Project Explorer. Also, if WebDriver is an Interface, the classes like ChromeDriver or InternetExplorerDriver which implement it should be defining the methods like.get()
or.getCurrentUrl()
. Where can we see the method definition of these methods?