Vba 如何使用Selenium(Windows 10)运行chromedriver?
我正在尝试使用以下环境自动化web浏览器: Windows10、Selenium(v3.141.0)、Python(v3.7.4)、chrome(v77.0.3865.90)和chromedriver(v77.0.3865.40)。我安装了pip,安装了Selenium(使用Python),在环境变量中设置了路径,调用了chromedriver的路径,但我仍然遇到了一些问题 -用于chromedriver的路径:“C:\webdrivers\chromedriver.exe” -Python路径:“C:\Users\linds\AppData\Local\Programs\Python\Python37” 我有一些代码在下面运行时出错了。有什么想法吗Vba 如何使用Selenium(Windows 10)运行chromedriver?,vba,selenium,selenium-webdriver,selenium-chromedriver,Vba,Selenium,Selenium Webdriver,Selenium Chromedriver,我正在尝试使用以下环境自动化web浏览器: Windows10、Selenium(v3.141.0)、Python(v3.7.4)、chrome(v77.0.3865.90)和chromedriver(v77.0.3865.40)。我安装了pip,安装了Selenium(使用Python),在环境变量中设置了路径,调用了chromedriver的路径,但我仍然遇到了一些问题 -用于chromedriver的路径:“C:\webdrivers\chromedriver.exe” -Python路径
>>> from selenium import webdriver
>>> from selenium.webdriver.chrome.options import Options
>>> options = Options()
>>> options.add_argument('--headless')
>>> options.add_argument('--no-sandbox')
>>> options.add_argument('--disable-gpu')
>>> driver = webdriver.Chrome(options=options, executable_path='C:\webdrivers\chromedriver.exe')
Traceback (most recent call last):
File "<pyshell#31>", line 1, in <module>
driver = webdriver.Chrome(options=options, executable_path='C:\webdrivers\chromedriver.exe')
File "C:\Users\linds\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "C:\Users\linds\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\linds\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\linds\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\linds\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create a Chrome process.
来自selenium导入webdriver的>
>>>从selenium.webdriver.chrome.options导入选项
>>>选项=选项()
>>>options.add_参数('--headless')
>>>options.add_参数('--no sandbox')
>>>options.add_参数('--disable gpu')
>>>driver=webdriver.Chrome(options=options,可执行文件\u path='C:\webdrivers\chromedriver.exe')
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
driver=webdriver.Chrome(options=options,可执行文件\u path='C:\webdrivers\chromedriver.exe')
文件“C:\Users\linds\AppData\Local\Programs\Python\37\lib\site packages\selenium\webdriver\chrome\webdriver.py”,第81行,在u init中__
期望的_能力=期望的_能力)
文件“C:\Users\linds\AppData\Local\Programs\Python\37\lib\site packages\selenium\webdriver\remote\webdriver.py”,第157行,在uu init中__
启动会话(功能、浏览器配置文件)
文件“C:\Users\linds\AppData\Local\Programs\Python\37\lib\site packages\selenium\webdriver\remote\webdriver.py”,第252行,在启动会话中
响应=self.execute(Command.NEW_会话,参数)
文件“C:\Users\linds\AppData\Local\Programs\Python\37\lib\site packages\selenium\webdriver\remote\webdriver.py”,执行中第321行
self.error\u handler.check\u响应(响应)
文件“C:\Users\linds\AppData\Local\Programs\Python37\lib\site packages\selenium\webdriver\remote\errorhandler.py”,第242行,在check\u响应中
引发异常类(消息、屏幕、堆栈跟踪)
selenium.common.exceptions.WebDriverException:消息:未知错误:无法创建Chrome进程。
我对这个问题的解决方案非常感兴趣。由于同样的问题,我不得不改用Python和selenium。了解最新的chrome、chromedriver和windows组合对人们有用,这将是一件有趣的事情。相关但至少在我的案例中不是一个解决方案:@Qharr-这就是它应该做的。它正在等待连接。@DebanjanB将是帮助的理想人选now@DebanjanB有错误的更新帖子有用吗?我对解决这个问题很感兴趣。由于同样的问题,我不得不改用Python和selenium。了解最新的chrome、chromedriver和windows组合对人们有用,这将是一件有趣的事情。相关但至少在我的案例中不是一个解决方案:@Qharr-这就是它应该做的。它正在等待连接。@DebanjanB将是帮助的理想人选now@DebanjanB带有错误的更新帖子有帮助吗?