赞
踩
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://www.baidu.com')
driver.close()
D:\python\python.exe D:\pycode\mypycode\case\test06_login.py Traceback (most recent call last): File "D:\python\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start creationflags=self.creationflags) File "D:\python\lib\subprocess.py", line 775, in __init__ restore_signals, start_new_session) File "D:\python\lib\subprocess.py", line 1178, in _execute_child startupinfo) FileNotFoundError: [WinError 2] 系统找不到指定的文件。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:\pycode\mypycode\case\test06_login.py", line 9, in <module> driver = webdriver.Chrome() File "D:\python\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__ service_log_path, service, keep_alive) File "D:\python\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 90, in __init__ self.service.start() File "D:\python\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
查询了浏览器版本:117.0.5927
但是国内的镜像网找不到,只更新到114版本
需要安装驱动,点击了最下面的网址https://chromedriver.chromium.org/home
如图为有效信息 - 点击跳转:https://googlechromelabs.github.io/chrome-for-testing
(点击这里直接找到114以后的版本)
找到对应版本,点击下载即可
解压到python.exe目录下
配置用户变量
重启pycharm
from selenium import webdriver
from time import sleep
driver = webdriver.Chrome()
driver.get('http://www.baidu.com')
sleep(3)
driver.close()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。