What is the difference between webdriver.Firefox() and webdriver.Firefox() in selenium?

前端 未结 2 488
夕颜
夕颜 2021-01-27 07:53

I looked through the selenium 3 for python documentation but still couldn’t get the difference between these two different driver calls.

webdriver.Firefox() 
         


        
2条回答
  •  误落风尘
    2021-01-27 08:45

    If you define the path for the driver, Functional call look for the file in the path and works accordingly. Second function driver.Firefox() / driver.Chrome() looks for existing software in the system. if the browser is not present you'll be getting following error.

     WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 
    

    My take is always use absolute path for the driver definition.

    from selenium import webdriver
    from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
    binary = FirefoxBinary('path/to/installed firefox binary')
    driver = webdriver.Firefox(firefox_binary=binary)
    

提交回复
热议问题