from selenium import webdriver
from time import sleep
from selenium.webdriver import ActionChains
driver = webdriver.Firefox()
action = ActionChains(driver)
URL = r"C:\Users\I\Desktop\注册A.html"
driver.get(URL)
ele = driver.find_element_by_css_selector("#userA")
# 鼠标的右键单击
action.context_click(ele).perform()
# 鼠标的左键双击
ele.send_keys("admin")
action.double_click(ele).perform()
sleep(3)
driver.quit()
----------------------------------------------------------------------
----------------------------------------------------------------------
from selenium import webdriver
from time import sleep
from selenium.webdriver import ActionChains
driver = webdriver.Firefox()
action = ActionChains(driver)
URL = r"C:\Users\I\Desktop\drop.html"
driver.get(URL)
# 鼠标的拖拽
source = driver.find_element_by_css_selector("#div1")
target = driver.find_element_by_css_selector("#div2")
# # 需求一:定位红色方框,蓝色方框,将红色方框拖拽覆盖到蓝色方框
action.drag_and_drop(source, target).perform()
# 需求二:定位红色方框,并拖拽到180,120的位置
action.drag_and_drop_by_offset(source, 180, 120).perform()
sleep(3)
driver.quit()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。