user8337986
user8337986

Reputation:

NotADirectoryError: [Errno 20] Not a directory: '/home/ghost/automation/pwd/geckodriver' with GeckoDrriver Firefox and Selenium using Python3

im using pycharm and my pythn

version 3.6.7 pip 9.0.1

and selenium version selenium-3.141.0 urllib3-1.24.1

i install selenium using this commands

pip3 install selenium  

then i code like this

from selenium import webdriver

driver = webdriver.Firefox("/home/ghost/automation/pwd/geckodriver")

driver.set_page_load_timeout(30)
driver.get("https://www.google.com/")
driver.maximize_window()
driver.implicitly_wait(120)
driver.get_screenshot_as_file("google.png")
driver.quit()

**when i run this i get this error **

/home/ghost/PycharmProjects/try/venv/bin/python /home/ghost/PycharmProjects/try/open/testcas1.py
Traceback (most recent call last):
  File "/home/ghost/PycharmProjects/try/open/testcas1.py", line 3, in <module>
    driver = webdriver.Firefox("/home/ghost/automation/pwd/geckodriver")
  File "/home/ghost/PycharmProjects/try/venv/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 151, in __init__
    firefox_profile = FirefoxProfile(firefox_profile)
  File "/home/ghost/PycharmProjects/try/venv/lib/python3.6/site-packages/selenium/webdriver/firefox/firefox_profile.py", line 80, in __init__
    ignore=shutil.ignore_patterns("parent.lock", "lock", ".parentlock"))
  File "/usr/lib/python3.6/shutil.py", line 309, in copytree
    names = os.listdir(src)
NotADirectoryError: [Errno 20] Not a directory: '/home/ghost/automation/pwd/geckodriver'

Process finished with exit code 1

and in this line driver = webdriver.Firefox("/home/ghost/automation/pwd/geckodriver") its correct path of my geckodriver nd my geckodriver version is 0.23.0

these answers are not help to me

https://stackoverflow.com/a/40399367/8337986 https://stackoverflow.com/a/42945346/8337986

Upvotes: 6

Views: 12207

Answers (2)

undetected Selenium
undetected Selenium

Reputation: 193338

In Brief

Need to use the param key executable_path

In Details

While working with GeckoDriver, Firefox and Selenium, you need to use the Key executable_path and the Value set to the absolute path of the GeckoDriver within single quotes i.e. '...' with forward slash i.e. / as path separator as follows:

driver = webdriver.Firefox(executable_path='/home/ghost/automation/pwd/geckodriver')

or use default location

driver = webdriver.Firefox(executable_path=GeckoDriverManager(cache_valid_range=1).install())

Upvotes: 14

Ramirez
Ramirez

Reputation: 1

I just put the geckodriver.exe file to my main project folder and identified link as: driver=webdriver.Firefox("D:\Desktop\project") without geckodriver, everything worked.

try whith

  • "/home/ghost/automation/pwd"

or

  • "\\home\\ghost\\automation\\pwd",
  • "\home\ghost\automation\pwd"

if you using Atom IDE maybe your problem is you run a .py file with a script package. It's working not same as cmd console

Upvotes: 0

Related Questions