faisal abdulai
faisal abdulai

Reputation: 3819

selenium.common.exceptions.WebDriverException: Message: 'library' executable may have wrong permissions for ChromeDriver

I want to use the chrome webdriver to connect to "https://www.google.com". below is the code.

from selenium import webdriver  
import time  

driver = webdriver.Chrome("C:\\Users\\faisal\\library")  
driver.set_page_load_timeout(10)  
driver.get("https://www.google.com")  
driver.find_element_by_name("q").send_keys(" automation by name ")  
driver.find_element_by_name("blink").click()  
time.sleep(5)  
driver.close()  

When I run the test, the following error message is displayed.Its a permission problem

C:\Users\faisal\PycharmProjects\firstSeleniumTest2\venv\Scripts\python.exe C:/Users/faisal/PycharmProjects/firstSeleniumTest2/test.py
Traceback (most recent call last):
  File "C:\Users\faisal\PycharmProjects\firstSeleniumTest2\venv\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Python\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Python\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/faisal/PycharmProjects/firstSeleniumTest2/test.py", line 4, in <module>
    driver = webdriver.Chrome("C:\\Users\\faisal\\library")
  File "C:\Users\faisal\PycharmProjects\firstSeleniumTest2\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
    self.service.start()
  File "C:\Users\faisal\PycharmProjects\firstSeleniumTest2\venv\lib\site-packages\selenium\webdriver\common\service.py", line 88, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'library' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home


Process finished with exit code 1

Upvotes: 8

Views: 23302

Answers (6)

user8735309
user8735309

Reputation: 1

I had to use the following to run on Windows 10 64 bit and 32 bit chromedriver:

driver = webdriver.Chrome(executable_path=r'C:\\Users\\My Name\\Downloads\\chromedriver_win32\\chromedriver.exe')

Upvotes: 0

vaidehi joshi
vaidehi joshi

Reputation: 1

The executable_path should have chromedriver added at last:

executable_path='/home/selenium/Linkedin-Automation/chromedriver'

Upvotes: 0

Trect
Trect

Reputation: 2965

In case of Linux providing permission will solve the problem.

Use

sudo chmod +x chromedriver

Upvotes: 2

Muhammad Anas
Muhammad Anas

Reputation: 1

driver=webdriver.Chrome("C:\\Users\\SQA Anas\\Downloads\\chromedriver.exe")

Please enter the complete chrome driver path like this: "C:\Users\SQA Anas\Downloads\chromedriver.exe"

Its works for me :)

Upvotes: 0

undetected Selenium
undetected Selenium

Reputation: 193338

The error says it all :

selenium.common.exceptions.WebDriverException: Message: 'library' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

In you code block you mentioned :

driver = webdriver.Chrome("C:\\Users\\faisal\\library")

The error clearly says your program was considering library as the ChromeDriver binary. Hence the error.

But as per the documentation of selenium.webdriver.chrome.webdriver the call to the WebDriver() is as :

class selenium.webdriver.chrome.webdriver.WebDriver(executable_path='chromedriver', port=0, options=None, service_args=None, desired_capabilities=None, service_log_path=None, chrome_options=None)

So you need to change send the Key executable_path along with the Value as the absolute path within single qoute '' along with the raw (r) switch as follows :

driver = webdriver.Chrome(executable_path=r'C:\Users\faisal\library\chromedriver.exe')

Update

As per the counter question from @Mangohero1 of-coarse executable_path is optional but in case you provide only the absolute path as per the source code provided below the absolute path is considered as the Value to the Key executable_path.

class WebDriver(RemoteWebDriver):
    """
    Controls the ChromeDriver and allows you to drive the browser.

    You will need to download the ChromeDriver executable from
    http://chromedriver.storage.googleapis.com/index.html
    """

    def __init__(self, executable_path="chromedriver", port=0,
         options=None, service_args=None,
         desired_capabilities=None, service_log_path=None,
         chrome_options=None):
    """
    Creates a new instance of the chrome driver.

    Starts the service and then creates new instance of chrome driver.

    :Args:
     - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH

Upvotes: 9

C:\Users\faisal\library is not the correct path to chromedriver. Give the actual path to your chromedriver file.

Upvotes: 4

Related Questions