why we assign firefoxdriver instance to webdriver

前端 未结 8 1627
时光说笑
时光说笑 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:30

    I know that this is kind of Late binding in Java,

    No. This is an example of compile time binding. But yes, it's also an example of programming to the WebDriver interface.

    Question1: But this applies [sic] to classes, right?

    It could (conceivably) be an interface that extends WebDriver.

    Question2: WebDriver is an interface, then can we create an object instance of an interface?

    Yes, you can create concrete instances that implement an interface. In fact, to use any interface there must be at least one concrete implementation.

提交回复
热议问题