why we assign firefoxdriver instance to webdriver

前端 未结 8 1630
时光说笑
时光说笑 2021-02-06 16:52

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

8条回答
  •  青春惊慌失措
    2021-02-06 17:14

    Webdriver is an interface, not a class. We create a Webdriver reference driver and assign it to an object of class FirefoxDriver. To perform the testing on Firefox, make an object of class FirefoxDriver. Likewise, to test on chrome, use Chromedriver class' object and assign it to Webdriver. Webdriver is an interface which is implemented by both FirefoxDriver class and ChromeDriver class(and classes for other browsers like IE, Safari). Objects of only those classes can be assigned to an interface reference which implement that interface(which in this case is Webdriver interface)

提交回复
热议问题