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, 2019 in Selenium by Kartik

edited Jul 31, 2019 4,427 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, 2019 by Anvi
• 14,150 points

Related Questions In Selenium

0 votes
1 answer
0 votes
2 answers

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

some of the controls not have id ...READ MORE

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
1,795 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, 2019 in Selenium by Anvi
• 14,150 points
15,838 views
0 votes
2 answers

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,500 points
13,674 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,143 views
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,910 points
7,221 views
+1 vote
2 answers

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

FindElement Command -This method locates for the ...READ MORE

answered Feb 11, 2020 in Selenium by anonymous
8,368 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, 2019 in Selenium by Abha
• 28,140 points
2,151 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP