ChromeDriver权限错误求助:使用ChromeDriver访问Google失败
Hey there, let's break down what's going wrong and fix your script step by step!
First, the Core Problem: Incorrect ChromeDriver Path & Permissions
The error selenium.common.exceptions.WebDriverException: Message: 'library' executable may have wrong permissions pops up for two key reasons:
- You're pointing
webdriver.Chrome()to a folder path (C:\\Users\\faisal\\library) instead of the actual ChromeDriver executable file. - Even if you had the right path, the executable might not have proper read/run permissions for your user account.
Step 1: Correct the ChromeDriver Path
ChromeDriver is an executable file (on Windows, it's chromedriver.exe). You need to provide the full path to this file, not just the folder it's in:
- Make sure you've downloaded the ChromeDriver version that matches your Chrome browser version.
- Update the path in your code to point directly to the
.exefile:driver = webdriver.Chrome("C:\\Users\\faisal\\library\\chromedriver.exe")
Step 2: Fix Permissions for ChromeDriver
If you still get permission errors after fixing the path:
- Locate the
chromedriver.exefile in yourlibraryfolder. - Right-click it → Select Properties → Go to the Security tab.
- Check that your user account has the Read & Execute permission enabled. If not, click Edit to add this permission for your account.
Step 3: Fix the Search Button Element (Bonus!)
Your script tries to click an element with name="blink"—that's not a valid element on Google's search page. The correct submit button has a name attribute of btnK (or btnI for "I'm Feeling Lucky"). Alternatively, you can just call .submit() on the search box, which is more reliable.
Corrected Full Script
from selenium import webdriver import time # Point to the actual chromedriver executable driver = webdriver.Chrome("C:\\Users\\faisal\\library\\chromedriver.exe") driver.set_page_load_timeout(10) driver.get("https://www.google.com") # Locate search box and enter query search_box = driver.find_element_by_name("q") search_box.send_keys("automation by name") # Submit the search (either method works) search_box.submit() # Or use the button: driver.find_element_by_name("btnK").click() time.sleep(5) driver.quit() # Use quit() to close the entire browser process, not just one tab
Quick Notes
- Always match your ChromeDriver version to your installed Chrome browser version—mismatches cause weird errors too!
- Using
driver.quit()instead ofdriver.close()is better practice, as it cleans up the entire browser process rather than just closing a single tab.
内容的提问来源于stack exchange,提问作者faisal abdulai

