Is this correct - FirefoxDriver driver = new FirefoxDriver();?

允我心安 提交于 2019-12-04 05:23:27

问题


I have seen almost everybody using the statement WebDriver driver=new FirefoxDriver(); here we have created an instance of FirefoxDriver class having type as Webdriver; What if i directly create an instance of FirefoxDriver as FirefoxDriver driver = new FirefoxDriver(); I have gone through many discussion where it is said that Webdriver is an interface. I know what interface is and how it works. I want to know if FirefoxDriver driver = new FirefoxDriver(); is correct when i know that Firefox is the only browser i am gonna use in my selenium script?


回答1:


As you mentioned in your question that know that Firefox is the only browser you are gonna use in your selenium script then there is no constraint in using the following line of code :

FirefoxDriver driver = new FirefoxDriver();

Here you can find a detailed discussion on What is the difference between ChromeDriver and WebDriver in selenium?



来源:https://stackoverflow.com/questions/49996626/is-this-correct-firefoxdriver-driver-new-firefoxdriver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!