可能是因为你的计算机上没有安装对应的浏览器驱动程序。根据你使用的浏览器类型和版本,在官方网站上下载对应的驱动程序,将其添加到系统环境变量中。
可以尝试在代码中添加以下内容,以确保Selenium使用正确的浏览器驱动程序:
from selenium import webdriver
# 设置浏览器驱动路径
driver_path = "path/to/driver"
# 创建浏览器对象
browser = webdriver.Chrome(executable_path=driver_path)
# 打开网页
browser.get("https://www.google.com")
下载对应的驱动 https://chromedriver.storage.googleapis.com/index.html
返回的坐标大多为文字左上角 所以点击位置往右下偏移
for e in word_xy:
xx = e[0] + 4
yy = e[1] + 8
ActionChains(driver).move_to_element_with_offset(pic_tag,xx,yy).click().perform()
time.sleep(0.5)#点击间歇0.5秒 防止反应不过来