我只是在尝试使用selenium在Mac上做一些非常基础的事情,甚至无法打开网页。我收到一个错误:
Traceback (most recent call last): File "/Users/godsinred/Desktop/InstagramLiker/GmailAccountGenerator.py", line 10, in <module> driver = webdriver.Chrome() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__ self.service.start() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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: 'chromedriver' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
这是我的代码如下:
from selenium import webdriver import time link = "https://accounts.google.com" driver = webdriver.Chrome() driver.get(link) time.sleep(5) driver.quit()
错误说明了一切:
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
该错误明确提到正在检测到的 chromedriver 具有错误的权限。
在启动 WebDriver 和 WebClient时, 将参数 execute_path连同chromedriver 二进制 文件 的绝对路径一起传递,如下所示: __
from selenium import webdriver
link = "https://accounts.google.com“ driver = webdriver.Chrome(executable_path=’/path/to/chromedriver’) driver.get(link)
您可以在以下位置找到详细的相关讨论: