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

标签 python selenium selenium-webdriver selenium-chromedriver chrome-web-driver

我想使用 chrome webdriver 连接到“https://www.google.com”。
下面是代码。

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

当我运行测试时,显示以下错误消息。这是一个权限问题
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

最佳答案

C:\Users\faisal\library不是 chromedriver 的正确路径。提供 chromedriver 文件的实际路径。

关于python - selenium.common.exceptions.WebDriverException : Message: 'library' executable may have wrong permissions for ChromeDriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49594492/

相关文章:

python - 使用 uvicorn 运行时,fastapi 找不到模型定义

python - 使用networkx和matplotlib时如何使x和y轴出现?

java - Selenium WebDriver、使用 Java 的 TestNG

python - 为什么我在使用 TensorFlow CLI Debugger 时得到 "_curses.error: cbreak() returned ERR"?

python - Scipy:如何将 KD-Tree 距离从查询转换为千米(Python/Pandas)

c# - 使用 Selenium WebDriver 与 native javascript 衡量性能

php - 如何通过apache服务器执行php调用的带有selenium的python脚本?

python - Selenium 驱动程序: How to find the element added after the webpage is loaded?

java - 选择复选框时在 katalon 中出现过时元素异常

java - WebDriver - 处理 HTML 弹出窗口