NotADirectoryError: [WinError 267] The directory name is invalid error while invoking Firefox through Selenium Python

前端 未结 2 1132
伪装坚强ぢ
伪装坚强ぢ 2021-02-05 23:10

I\'m trying to invoke a firefox browser using Selenium webdriver from below python code..

from selenium import webdriver

# Initializing the WebDriver for Firef         


        
相关标签:
2条回答
  • 2021-02-05 23:56

    You need to take care of a couple of things as follows :

    • You need to pass the Key executable_path along with the Value referring to the absolute path of the GeckoDriver through single backslash i.e. \ along with the raw i.e. r switch as follows :

      from selenium import webdriver
      
      driver = webdriver.Firefox(executable_path=r'C:\selenium\mozilla\geckodriver.exe')
      driver.set_page_load_timeout(30)
      driver.get("https://www.google.com/")
      driver.quit()
      
    • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.

    • Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
    • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
    • Take a System Reboot.
    • Execute your @Test.
    0 讨论(0)
  • 2021-02-06 00:06

    Selenium is looking for the directory, not the executable. You have to point to the directory where geckodriver.exe is placed. Do not include geckodriver.exe in the string argument.

    Instead of

    driver = webdriver.Firefox("C:\\selenium\\mozilla\\geckodriver.exe")
    

    Do

    driver = webdriver.Firefox("C:\\selenium\\mozilla")
    
    0 讨论(0)
提交回复
热议问题