1

Without using webdriver, I observed that driver.FindElement method have return type as WebElement-Remotewebdriver.

With using Webdriver,I observed that FindElement method have return type as WebElement-Webdriver.

ChromeDriver driver = new ChromeDriver();

driver.get("https://ui.freecrm.com/");

driver.findElement(By.xpath("//div[@class='ui fluid large blue submit button']"));

If Chromedriver is implementing the Webdriver interface, why I am seeing the return type of findElement as Webelement-RemoteWebdriver rather than Webelement-Webdriver?

And I know that RemoteWebdriver class implements Webdriver interface. When the remotewebdriver will be used and why?

cruisepandey
  • 28,520
  • 6
  • 20
  • 38
  • 2
    How do you run a Selenium test *without* using WebDriver? – JeffC May 15 '19 at 16:31
  • 1
    This is a rehash of [Can we run selenium tests without using Webdriver interface in your code?](https://stackoverflow.com/questions/56149640/can-we-run-selenium-tests-without-using-webdriver-interface-in-your-code) – Ardesco May 15 '19 at 17:33

1 Answers1

1

SearchContext is a root interface that is extended by webdriver and webelement interface.

So when we talk about webdriver interface, there are two classes that implements this interface

  • EventFiringWebDriver.
  • RemoteWebDriver.

There are 6 classes that extends RemoteWebDriver class like ChromeDriver, FF, IE, etc.

See what the official documents says :

You can use WebDriver remotely the same way you would use it locally. The primary difference is that a remote WebDriver needs to be configured so that it can run your tests on a separate machine. A remote WebDriver is composed of two pieces: a client and a server. The client is your WebDriver test and the server is simply a Java servlet, which can be hosted in any modern JEE app server.

For more you can refer : official Link

Q. If Chromedriver is implementing the Webdriver interface, why I am seeing the return type of findElement as Webelement-RemoteWebdriver rather than Webelement-Webdriver?

Ans : Chromedriver is a public class which do not implement Webdriver interface. and extends RemoteWebDriver protected class.

cruisepandey
  • 28,520
  • 6
  • 20
  • 38
  • In the below link, i see that Chromedriver implements the webdriver. I am little confused here. Can you please explain liitle bit more https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/chrome/ChromeDriver.html – Bhaskar1234 May 16 '19 at 03:02