Balaji Santhanam
Balaji Santhanam

Reputation: 31

Need logical clarification in WebDriver interface and ChromeDriver class

Can you please clarify my doubt:

WebDriver driver = new ChromeDriver();

  1. we know WebDriver is an in Interface and the Chrome Driver is class, which is implementing the

WebDriver Interface.

That means, what ever the methods defined in Interface we are just Overriding the same with Chrome Driver Class.

  1. ChromeDriver driver = new ChromeDriver();

Now, if we write the code like above....Still we can run the code.

Now my doubts are:

  1. We are not relate to Webdriver Interface here. But Still Code will run and execute the methods successfully...How? Because in ChromeDriver class we dont have methds like:

getTitle(), getCurrentUrl() etc. These methods are absolutely relate to the WebDriver Interface.

  1. ChromeDriver is class and creating the Object for the same and getting the methods with Object.

And with the creation ofObject how we get the methods like : getTitle(), getCurrentUrl()

through ChromeDriver Object?

Upvotes: 0

Views: 786

Answers (1)

Amit Kumar
Amit Kumar

Reputation: 94

Answer to all your doubts is :

  1. All the abstract methods of WebDriver interface are implemented in RemoteWebDriver class which is extended by browser classes such as Chrome Driver etc. And All the abstract methods of WebDriver interface are implemented in RemoteWebDriver class. Thats why , you can get the methods like getTitle(), getCurrentUrl() through ChromeDriver Object.

I hope this helps you enter image description here

Upvotes: 2

Related Questions