selenium 报错
开始学自动化测试,,环境配了一天TAT
安装好selenium之后
运行python脚本
# coding=utf-8
from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
time.sleep(3)
driver.quit()
疯狂报错
selenium.common.exceptions.NoSuchDriverException: Message: Unable to
obtain driver for chrome using Selenium Manager.; For documentation on
this error, please visit:
https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
网上查了一下,没找到有用的
都是driver = webdriver.Chrome(Chromedriver地址)
因为selenium升级了我的是4.16

这里定义已经改了
所以通过service来传地址
from selenium.webdriver.edge.service import Service
ser = Service()
ser.path = r'D:\useful\python3\chromedriver.exe'
driver = webdriver.Chrome(service=ser)
报错2
urllib3.exceptions.ProxySchemeUnknown: Proxy URL had no scheme, should start with http:// or https://
不知道啥原因,我也没开代理
google搜到再加一个这个
from selenium.webdriver.chrome.options import Options
opts = Options()
opts.ignore_local_proxy_environment_variables()
总的代码
# coding=utf-8
from selenium import webdriver
import time
from selenium.webdriver.edge.service import Service
from selenium.webdriver.chrome.options import Options
opts = Options()
opts.ignore_local_proxy_environment_variables()
ser = Service()
ser.path = r'D:\useful\python3\chromedriver.exe'
driver = webdriver.Chrome(options=opts,service=ser)
driver.get("https://www.baidu.com") # 打开百度浏览器
time.sleep(3) #等待3秒
driver.quit() #关闭浏览器
成功啦



![力扣每日一题day36[112.路径总和]](https://img-blog.csdnimg.cn/img_convert/a1f33da4343b6696b8b450f7cd199895.jpeg)













![[XR806开发板试用] XR806——基于FreeRTOS下部署竞技机器人先进模糊控制器](https://img-blog.csdnimg.cn/direct/c524f89813964012a15cb5cefaccf3f1.png)

