seleniumselenium-webdriverwebdriverremotewebdriver

Difference between running Selenium test with using Webdriver and without using webdriver


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?


Solution

  • 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

    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.