I am novice to Java or Selenium.
I just need help to understand one basic question.
Why we assign firefoxdriver instance to WebDriver? WebDriver driver=new Firef
WebDriver is an interface and FirefoxDriver is a class which implements this WebDriver contract. See Selenium doc enter link description here
Now we can create a reference variable of an interface but we can't instantiate any interface since it is just a contract to be implemented.But we can assign the instance of a class (In this case FirefoxDriver ) to its Parents(WebDriver).
We can assign child classes to its parents(It may be a class or an interface to which it extends/implements).
Now The reason behind doing WebDriver driver=new FirefoxDriver() is just to create an abstraction to the client(Java Program) because you can use Any Driver class according to browser.