元素拖拽操作

 1 # -*- coding:utf-8 -*-
 2 
 3 from selenium import webdriver
 4 from selenium.webdriver import ActionChains
 5 
 6 driver = webdriver.Firefox()
 7 
 8 driver.get(r'F:\电子书\selenium\Selenium Testing Tools Cookbook(中文)\demo\DragAndDrop.html')
 9 
10 source = driver.find_element_by_id('draggable')     #被移动的源元素
11 target = driver.find_element_by_id('droppable')     #目标元素
12 
13 builder = ActionChains(driver)
14 
15 builder.drag_and_drop(source, target).perform()         #移动元素

 

posted @ 2013-06-23 20:03  Roger|  阅读(176)  评论(0编辑  收藏  举报