24 lines
701 B
Python
24 lines
701 B
Python
# -*- encoding:utf-8 -*-
|
|
|
|
'''
|
|
@Author : dingjiawen
|
|
@Date : 2023/12/6 20:08
|
|
@Usage :
|
|
@Desc :selenium动作链 一系列动作连续执行
|
|
'''
|
|
|
|
from selenium import webdriver
|
|
from selenium.webdriver import ActionChains
|
|
from selenium.webdriver.common.by import By
|
|
|
|
browser = webdriver.Chrome()
|
|
url = 'http://www.runoob.com/try/try.php?filename=jqueryui-api-droppable'
|
|
browser.get(url)
|
|
browser.switch_to.frame('iframeResult')
|
|
source = browser.find_element(By.CSS_SELECTOR, '#draggable')
|
|
target = browser.find_element(By.CSS_SELECTOR, '#droppable')
|
|
actions = ActionChains(browser)
|
|
# 模拟鼠标的点击与放下
|
|
actions.drag_and_drop(source, target)
|
|
actions.perform() # 正式执行上述模拟操作
|