# -*- coding: utf-8 -*-
#鼠标事件

#ActionChains类中包括:

                      # context_click()  右击;
                        # double_click() 双击;
                        # drag_and_drop() 拖动;
                        # move_to_element()鼠标悬停在一个元素上;
#首先引入ActionChains

from selenium.webdriver.common.action_chains import ActionChains
from selenium import webdriver
driver = webdriver.Firefox()

driver.get('http://www.baidu.com')

#定位到要操作的元素
target_element = driver.find_element_by_id('xx')
#执行ActionChains中存储的行为,需要用perform()
#右击元素
ActionChains(driver).context_click(target_element).perform()

#双击元素
ActionChains(driver).double_click(target_element).perform()

#拖动元素drag_and_drop(source,target)
source = driver.find_element_by_id('xx')
target = driver.find_element_by_id('yy')
ActionChains(driver).drag_and_drop(source,target).perform()

#鼠标悬停在一个元素上
ActionChains(driver).move_to_element(target_element).perform()

selenium python (三)鼠标事件的更多相关文章

  1. Selenium WebDriver 中鼠标事件(全)

    Selenium WebDriver 中鼠标事件(全) 鼠标点击操作  鼠标点击事件有以下几种类型:  清单 1. 鼠标左键点击   Actions action = new Actions(driv ...

  2. python+selenium_鼠标事件

    引言--在实际的web产品测试中,对于鼠标的操作,不单单只有click(),有时候还要用到右击.双击.拖动等操作,这些操作包含在ActionChains类中. 一.ActionChains类中鼠标操作 ...

  3. Selenium WebDriver 中鼠标事件

    鼠标点击操作  鼠标点击事件有以下几种类型:  清单 1. 鼠标左键点击   Actions action = new Actions(driver);action.click();// 鼠标左键在当 ...

  4. Selenium+Java(九)Selenium键盘与鼠标事件

    一.键盘事件 ctrl+a driver.findElement(By.id("kw")).sendKeys(Keys.CONTROL, "a"); ctrl+ ...

  5. Behave + Selenium(Python) 三

    来自T先生 通过之前的2篇文章,大家都了解了如果利用behave和selenium打开网页和进行基本的操作,但是这些对于项目来说,却是往往不够的. 如果对junit或者TestNG熟悉的人都知道有@B ...

  6. Selenium WebDriver中鼠标事件

    鼠标点击操作  鼠标点击事件有以下几种类型:  清单 1. 鼠标左键点击   Actions action = new Actions(driver);action.click();// 鼠标左键在当 ...

  7. selenium+python 移动鼠标方法

    from selenium import webdriver from selenium.webdriver.common.keys import Keys import time driver=we ...

  8. selenium 3.0鼠标事件 (java代码)

    注意:ActionChains下相关方法在当前的firefox不工作,建议使用谷歌浏览器. public static void main(String[] args) throws Interrup ...

  9. 【Selenium专题】鼠标键盘事件

    引用包来自selenium-java-2.23.1.jar 调用以下代码时,需要引入actions类,以java为例: import org.openqa.selenium.interactions. ...

随机推荐

  1. [iOS]URL编码和解码

    1. 首先来看下什么样的是URL编码(字符串中带有%22 类似这样的) NSString *str = @"http://m.tuniu.com/api/home/data/index/c/ ...

  2. 312. Burst Balloons

    题目: Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented ...

  3. 分析函数(Analytic Functions)

    在OLAP这类系统或者DW这类数据库中,作为某份报表的数据源,我们常常需要在某个存储过程中编写复杂的运算代码来汇总数据.分析函数便具备这样的能力,引用多行的数据值来进行多层面的聚合运算,在数据子集中进 ...

  4. Hadoop系列

    http://www.cnblogs.com/xia520pi/archive/2012/04/08/2437875.html#2925129 hadoop提供了一个可靠的共享存储和分析系统.HDFS ...

  5. 第一次做的struts2与spring整合

    参考:http://www.cnblogs.com/S-E-P/archive/2012/01/18/2325253.html 这篇文章说的关键就是“除了导入Struts2和Spring的核心库之外, ...

  6. 卷积神经网络和CIFAR-10:Yann LeCun专访 Convolutional Nets and CIFAR-10: An Interview with Yann LeCun

    Recently Kaggle hosted a competition on the CIFAR-10 dataset. The CIFAR-10 dataset consists of 60k 3 ...

  7. dojo 十二 rest

    从今年8月份开始一直在做以HTML5+CSS3+Dojo实现前端设计,以REST风格实现后台数据请求的项目研发.实践出真知,现在对研发中用到的技术和遇到的问题做一个总结. 后台服务没有采用那些主流的框 ...

  8. Ubuntu上安装Maven Eclipse以及配置

    通过官方网站  http://maven.apache.org/download.cgi     下载到当前的maven安装包 ubuntu解压安装文件我用的是ubuntu 12.10版本的命令:  ...

  9. kettle创建资源库

    手动修改一下这个表 R_VERSION INSERT INTO R_VERSION(ID_VERSION, MAJOR_VERSION, MINOR_VERSION, UPGRADE_DATE, IS ...

  10. Hosting Your Own NuGet Feeds

    Hosting Your Own NuGet Feeds Hosting the NuGet Gallery Locally in IIS https://github.com/NuGet/NuGet ...