0

I've downloaded the latest version of Firefox and corresponding (64 bit) geckodriver. Added the location of the geckodriver executable to PATH. Yet, when I execute the following code:

from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://www.google.com')

to call Firefox, I get the following error:

Traceback (most recent call last):
  File "C:\Users\Karun\Documents\NJCC all data at once Selenium.py", line 2, in <module>
    browser = webdriver.Firefox()
  File "C:\Users\Karun\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 162, in __init__
    keep_alive=True)
  File "C:\Users\Karun\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Users\Karun\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\Karun\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Karun\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: permission denied
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
coder101
  • 383
  • 4
  • 21

1 Answers1

0

The error you are seeing does gives us a hint about what could have gone wrong as follows :

Traceback (most recent call last):
  File "C:\Users\Karun\Documents\NJCC all data at once Selenium.py", line 2, in <module>
    browser = webdriver.Firefox()
selenium.common.exceptions.SessionNotCreatedException: Message: permission denied

Though you mentioned that you have added the location of the geckodriver executable to PATH but still facing the above mentioned error, so a simple solution will be to download the latest GeckoDriver from mozilla/geckodriver and pass the Key executable_path along with the Value of the absolute path of the GeckoDriver binary while initializing the webdriver and Web Browser instance as follows :

from selenium import webdriver

driver=webdriver.Firefox(executable_path=r'C:\path\to\geckodriver.exe')
driver.get("http://www.google.com")
print("Page Title is : %s" %driver.title)
driver.quit()

Additionally ensure that you are using :

  • The latest JDK version i.e. Java SE Development Kit 8u161
  • The latest Selenium Python Client i.e. Selenium 3.9.0
  • The latest GeckoDriver i.e. GeckoDriver v0.19.1
  • The latest Firefox version i.e. Firefox Quantum v58.0.2
  • Clean the Project Space from your IDE before and after your Tests.
  • Run CCleaner tool to wipe off the OS chores before and after executing your Test Suite.
  • If the base version of Firefox is too old uninstall Firefox through Revo Uninstaller and install a recent GA released version of Firefox.
  • Execute your Tests.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    Thank you all for your contributions. I removed all instances of geckodriver from my hard drive and reinstalled the driver, made sure that PATH included the directory where I installed the driver and restarted my system. And now it works fine. So it was probably a case of duplication of some sort. Thank you - appreciate your feedback. – coder101 Feb 17 '18 at 10:00