有些元素,明明定位而没错,但是一点击就报错,可能有鼠标悬浮动作。

# 鼠标悬浮
from selenium.webdriver import ActionChains

data_gslx = driver.find_element_by_xpath('//div[text()="有限责任公司"]')     #选择公司类型
action = ActionChains(driver)
action.move_to_element(data_gslx).perform()
time.sleep(0.2)
data_gslx.click()

没办法上传视频,图片效果不明显。就是鼠标放上去后元素会有动态变化 ,如果直接点击,则是无法定位到的。如下图,

原文地址:https://www.cnblogs.com/momoon/p/12230490.html