2

I'm trying to launch it after xvfb-run firefox but it returns me these mistakes. When I try to launch it with python3 command it returns me NotADirectoryError: [Errno 20] Not a directory: '/home/druid/.wdm/drivers/geckodriver/linux64/v0.31.0/geckodriver'

Here's a piece of my code: import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.support import expected_conditions as EC

def main():
    #options = webdriver.FirefoxOptions()
    #options.add_argument("--start-maximized")
    driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
5
  • can you share the selenium code, did you instal gecko driver? Commented Oct 9, 2022 at 20:37
  • @anarchy I used the webdriver_manager package Commented Oct 9, 2022 at 20:47
  • Are you on Ubuntu 22? Commented Oct 9, 2022 at 21:00
  • @BarrythePlatipus it's 18.04 Commented Oct 9, 2022 at 21:02
  • did you try to create this directory before running code? Commented Oct 9, 2022 at 22:34

1 Answer 1

1

First try this and try to run you code again,

sudo apt-get install firefox-geckodriver

If that doesn't work.

You can try to download the gecko driver manually. Then change the directory to the location of where you downloaded it to. Download from here, https://github.com/mozilla/geckodriver/releases unzip. Then change your code to this,

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.support import expected_conditions as EC

def main():
    options = webdriver.FirefoxOptions()
    #options.add_argument("--start-maximized")
    options.add_argument("--headless")

    driver = webdriver.Firefox(executable_path='/home/druid/path/to/geckodriver', options=options)

Your executable path is where you placed the geckodriver executable.

I have updated the code to start in headless mode because you mentioned you were getting an error as you are running this on a server.

Sign up to request clarification or add additional context in comments.

1 Comment

Comments are not for extended discussion; this conversation has been moved to chat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.