Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is webdriver a class or a interface?

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?

like image 264
Mainak Sikdar Avatar asked Jan 08 '23 13:01

Mainak Sikdar


1 Answers

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
   */
like image 163
Saifur Avatar answered Jan 11 '23 23:01

Saifur