WebDriverException: 'geckodriver' executable needs to be in PATH even though it is

后端 未结 1 781
予麋鹿
予麋鹿 2020-11-22 13:32

Trying to get firefox to run using selenium in spyder. My current code is

from selenium import webdriver
import os
os.environ[\"PATH\"] += \":/usr/local/bin/         


        
相关标签:
1条回答
  • 2020-11-22 13:56

    This error message...

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

    ...implies that the GeckoDriver wasn't found in the expected default location.

    Solution

    As you are using MAC based System you need to pass the Key executable_path along with the Value referring to the absolute path of the GeckoDriver as follows :

    from selenium import webdriver
    
    browser = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')
    

    Additional Consideration

    Ensure the following :

    • GeckoDriver is present in the specified location.
    • GeckoDriver is having executable permission for non-root users.
    • Execute your @Test as a non-root user.
    0 讨论(0)
提交回复
热议问题