Python 获取此selenium错误selenium.common.exceptions.WebDriverException:消息:'';可执行文件可能有错误的权限

Python 获取此selenium错误selenium.common.exceptions.WebDriverException:消息:'';可执行文件可能有错误的权限,python,selenium,intellij-idea,selenium-webdriver,selenium-chromedriver,Python,Selenium,Intellij Idea,Selenium Webdriver,Selenium Chromedriver,在我的IntellIJ上安装了Selenium。我正在努力完成练习2.1 在 这是我的代码: from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Chrome("C:\Python27\Scripts/") driver.get("http://www.python.org") assert "Python" in driver.title elem =

在我的IntellIJ上安装了Selenium。我正在努力完成练习2.1 在

这是我的代码:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome("C:\Python27\Scripts/")
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_class_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
这将产生以下错误:

Traceback (most recent call last):
  File "B:\Program Files (x86)\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
  File "B:\Program Files (x86)\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "B:\Program Files (x86)\lib\subprocess.py", line 990, 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 "B:/Alexander/Documents/PythonPrograms/Selenium/Test.py", line 3, in <module>
    driver = webdriver.Chrome("C:\Python27\Scripts/")
  File "B:\Program Files (x86)\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
    self.service.start()
  File "B:\Program Files (x86)\lib\site-packages\selenium\webdriver\common\service.py", line 86, in start
    os.path.basename(self.path), self.start_error_message)
**selenium.common.exceptions.WebDriverException: Message: '' executable may have wrong permissions**. Please see https://sites.google.com/a/chromium.org/chromedriver/home
回溯(最近一次呼叫最后一次):
文件“B:\Program Files(x86)\lib\site packages\selenium\webdriver\common\service.py”,第74行,在开始处
stdout=self.log\u文件,stderr=self.log\u文件)
文件“B:\Program Files(x86)\lib\subprocess.py”,第707行,在\uuu init中__
恢复信号,启动新会话)
文件“B:\Program Files(x86)\lib\subprocess.py”,第990行,在\u execute\u child中
startupinfo)
PermissionError:[WinError 5]访问被拒绝
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“B:/Alexander/Documents/PythonPrograms/Selenium/Test.py”,第3行,在
driver=webdriver.Chrome(“C:\Python27\Scripts/”)
文件“B:\Program Files(x86)\lib\site packages\selenium\webdriver\chrome\webdriver.py”,第62行,在\uuu init中__
self.service.start()
文件“B:\Program Files(x86)\lib\site packages\selenium\webdriver\common\service.py”,第86行,在开始处
os.path.basename(self.path)、self.start\u错误消息)
**selenium.common.exceptions.WebDriverException:消息:“”可执行文件可能具有错误的权限**。请看https://sites.google.com/a/chromium.org/chromedriver/home
看起来像这样:

def start(self):
<...>
    try:
        cmd = [self.path]
        cmd.extend(self.command_line_args())
        self.process = subprocess.Popen(cmd, <...>)
<...>
    except OSError as err:
<...>
        elif err.errno == errno.EACCES:
            raise WebDriverException(
                "'%s' executable may have wrong permissions. %s" % (
                    os.path.basename(self.path), self.start_error_message)

这意味着,
self.path
是传递给
webdriver.Chrome
的第一个参数,即
“C:\Python27\Scripts/”
。由于它随后作为要执行的程序传递给
子流程
它应该是指向可执行文件的路径,而不是指向目录的路径。根据上面搜索的其他结果判断,Chrome可执行文件的路径。在本例中,Firefox驱动程序是在没有参数的情况下启动的,但如搜索结果所示,它似乎具有来自配置文件或其他内容的自动检测功能。

我在这里没有看到任何问题。我收到了“selenium.common.exceptions.WebDriverException:消息:“”可执行文件可能有错误权限”,我不知道如何修复它。(OT)“B:\Program Files(x86)”?!我感觉有些人出生太晚了,看不到软盘时代……可能是无意屈尊的复制品。只是被“完全不尊重字母a:和B:)事实上,2000年后出生的ppl现在已经长大到可以编程了,这只是生活中的一个事实——不管你是不是一个ppl。
class Service:

    def __init__(self, executable, port=0, log_file=DEVNULL, env=None, start_error_message=""):
        self.path = executable
    <...>