Error: NotAValidDirectory:: The directory name is invalid: 'C:\\Users\\Kartik\\geckodriver.exe'

0 votes

I am trying to initialize Firefox driver on Python Selenium Webdriver using following code:

driver = webdriver.Firefox('C:\\Users\\Kartik\\geckodriver.exe')

Now this is showing the following error:

Error: NotAValidDirectory:: The directory name is invalid: 'C:\\Users\\Kartik\\geckodriver.exe'

I tried using single forward slashes in the driver path, but that's also causing the following problem:

File "C:\Users\Kartik\eclipse-workspace\pythonDemo\python_demo_package\AmazonLogin.py", line 17
    driver = webdriver.Firefox('C:\Users\Kartik\geckodriver.exe')
                              ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Jul 31 in Selenium by Kartik

edited Jul 31 49 views

1 answer to this question.

0 votes

Hey Kartik, Firefox requires gecko driver to launch the browser and to do the same, we need to use executable path to set the driver path in Python Webdriver. Try using following piece of code to resolve your issue:

driver = webdriver.Firefox(executable_path=r"C:\Users\Anvi_R\Downloads\ExtractedFiles\geckodriver.exe")
driver.implicitly_wait(2)
driver.maximize_window()

driver.get('https://www.gmail.com')
answered Jul 31 by Anvi
• 12,860 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

what is the need of xpath when you have attributes like id ,class,name in selenium?

It is not necessary that every element ...READ MORE

answered Jun 1, 2018 in Selenium by Vinita
• 220 points
164 views
+1 vote
2 answers
0 votes
1 answer

Installing Selenium Webdriver with Python package

Hey Hemant, for installing Selenium Webdriver with ...READ MORE

answered May 8 in Selenium by Anvi
• 12,860 points
143 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
577 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
898 views
0 votes
1 answer

What is the difference between findElement and findElements in Selenium Webdriver?

Hi Nilaabh, Selenium Webdriver uses findElement and ...READ MORE

answered May 8 in Selenium by Anvi
• 12,860 points
301 views
0 votes
2 answers

What is PhantomJS and what is the usage of it?

@Ojaswini, Phantomjs is used for automating webpage ...READ MORE

answered Aug 1 in Selenium by Abha
• 23,030 points
39 views