通过鼠标操作来模拟点击某元素
首先要导入包
from selenium.webdriver.common.action_chains import ActionChains
编写代码
el_login = dr.find_element_by_xpath(".//*[@id='dologin']")
mouse = ActionChains(dr)
mouse.click(el_login).perform()
登录按钮进行模拟点击
这样点击是通过寻找元素来指定点击位置,有些情况可能找不到元素(假装找不到)
那么我们可以通过鼠标悬停的操作,再去执行点击
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import time
dr = webdriver.Chrome("D:\chr