由selenium的ActionChains来模拟鼠标 *** 作,主要的 *** 作流程。
1、储存鼠标的 *** 作
2、perform()来执行鼠标的 *** 作。
支持的 *** 作如下:
double_click 双击 *** 作
context_click 右键 *** 作
drag_and_drop 拖拽 *** 作。 左键按住拖动某一个元素到另外一个区域,然后释放按键
move_to_element() 鼠标悬停,以后会经常遇到
细说:
perform() 比较特殊,先将 *** 作村放在一个列表中,然后用perform方法去全部执行列表中的 *** 作。
引用ActionChains类:
ActionChains(driver).click(xx).context_click().perform()
from selenium.webdriver.common.action_chains import ActionChains
ActionChains(driver).move_to_element(menu).click(hidden_submenu).perform() --连续 *** 作
actions = ActionChains(driver)
actions.move_to_element(menu)
actions.click(hidden_submenu)
actions.perform()
键盘 *** 作
下拉列表
上传JS处理
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)