webdriver是一个类还是一个接口?

Mai*_*dar 4 java selenium webdriver selenium-webdriver

Selenium文档中,WebDriver是一个接口,但在Eclipse中,包org.openqa.selenium在Project Explorer中显示为一个类.此外,如果WebDriver是一个接口,那么实现它的ChromeDriver或InternetExplorerDriver等类应该定义类似.get()或的方法.getCurrentUrl().我们在哪里可以看到这些方法的方法定义?

Sai*_*fur 6

WebDriver是一个公共界面,我不认为ChromeDriver或任何其他驱动程序实现WebDriver,而是扩展RemoteWebDriver这是一个类.

编辑

正如我所说,驱动程序扩展了RemoteWebDriver,并且具有这些方法的实际实现.

public void get(String url) {
   execute(DriverCommand.GET, ImmutableMap.of("url", url));
}
Run Code Online (Sandbox Code Playgroud)

Java来源:

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
   */
Run Code Online (Sandbox Code Playgroud)