WebDriver is a Class or an Interface?

922 views
Skip to first unread message

Sid

unread,
Sep 1, 2015, 9:34:47 AM9/1/15
to Selenium Users
According to javadoc WebDriver is an Interface.

But the rule says, We cannot create an object of an Interface.

So what is WebDriver, Class or Interface?

Krishnan Mahadevan

unread,
Sep 1, 2015, 9:46:28 AM9/1/15
to seleniu...@googlegroups.com
Sidharth,

WebDriver is an interface which RemoteWebDriver ( the mother of all WebDriver implementations ) implements. That explains why one is able to assign a concrete implementation object to the interface reference [ WebDriver driver = new FirefoxDriver() ] because all browser web driver implementations such as FirefoxDriver, ChromeDriver, InternetExplorerDriver etc., extend RemoteWebDriver and thus indirectly implement the WebDriver interface [ which is basically a contract that anyone who claims to support browser interaction has to adhere to ]


All said and done, there is NOTHING in Java that states that you cannot create an interface Object. Its called anonymous objects and Java very much supports it [ But then again, that’s completely out of scope of discussion in this forum, because we focus here on WebDriver/Selenium and not Java questions ]
You can read more about anonymous objects in this SO link : http://stackoverflow.com/questions/16880494/how-can-we-create-object-of-interface-in-java 


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Technical Scribbings @ http://rationaleemotions.wordpress.com/


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/00ac92c8-84b2-4fbf-be5c-97defc396028%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

anemuday

unread,
Sep 1, 2015, 2:18:09 PM9/1/15
to Selenium Users
Sid,

Please take a look at the below SO thread, which i asked couple of days ago.

Can we instansiate an Interface

I hope this helps.

Thanks,
Uday
Free Selenium WebDriver Videos
Reply all
Reply to author
Forward
0 new messages