selenium怎么打不开浏览器啊
from selenium import webdriverdriver = webdriver.Chrome()
driver.get("http://www.baidu.com")
各位大佬看看这个代码有问题吗,插件也下载了,但是运行后打不开浏览器,还报错。
C:\Users\c\AppData\Local\Programs\Python\Python38-32\python.exe H:/系统默认/桌面/工作/Python工程/1.py
Traceback (most recent call last):
File "H:/系统默认/桌面/工作/Python工程/1.py", line 2, in <module>
driver = webdriver.Chrome()
File "C:\Users\c\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
RemoteWebDriver.__init__(
File "C:\Users\c\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\c\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\c\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\c\AppData\Local\Programs\Python\Python38-32\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 Chrome process.
Process finished with exit code 1
应该是你没有添加那个插件的位置,这是我之前写的,用的edge,原理一样
driver_path = r'E:\python\edgedriver_win64\msedgedriver.exe'#浏览器路径
driver = webdriver.Edge(executable_path=driver_path)
driver.maximize_window()#最大化网页
driver.get("https://authserver.zjou.edu.cn/cas/login?service=http%3A%2F%2Fnewjwgl.zjou.edu.cn%2Feams%2Flogin.action")#打开指定网页
driver.refresh()#刷新屏幕 谷歌浏览器以及谷歌驱动 都下载了没 查一下兼容列表 wp231957 发表于 2021-9-30 06:17
谷歌浏览器以及谷歌驱动 都下载了没
都下载了,版本号也都对。 叶夜还 发表于 2021-9-30 20:22
都下载了,版本号也都对。
你的驱动文件放在哪个目录下? wp231957 发表于 2021-9-30 20:24
你的驱动文件放在哪个目录下?
在python安装目录下的scripts文件夹
页:
[1]