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

6

8

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
Chirp answered 1/4, 2018 at 3:22 Comment(0)
E
4

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

Edwinedwina answered 1/4, 2018 at 3:26 Comment(1)
actual path was : "C:\\Users\\faisal\\library\\chromedriver.exe" thanksChirp
P
9

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
Platitudinize answered 1/4, 2018 at 5:21 Comment(2)
Actually if i remember correctly explicitly setting the key executable_path is optional. But yes, it has to be the absolute path.Systemize
@Systemize Thanks, added an update as per your counter question. Let me know if any further queries.Platitudinize
E
4

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

Edwinedwina answered 1/4, 2018 at 3:26 Comment(1)
actual path was : "C:\\Users\\faisal\\library\\chromedriver.exe" thanksChirp
T
2

In case of Linux providing permission will solve the problem.

Use

sudo chmod +x chromedriver
Thach answered 23/7, 2019 at 17:45 Comment(0)
L
0

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 :)

Lecia answered 12/3, 2019 at 11:18 Comment(0)
C
0

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')
Cabana answered 18/5, 2020 at 15:1 Comment(0)
C
0

The executable_path should have chromedriver added at last:

executable_path='/home/selenium/Linkedin-Automation/chromedriver'
Crosspatch answered 29/12, 2020 at 10:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.