selenium Python自动化测试(基本的鼠标事件)
来源:互联网 发布:海口Java招聘 编辑:程序博客网 时间:2024/06/07 18:32
#coding=utf-8
'''
Created on 2015-5-8
@author: user
简单的鼠标事件以及使用方法!!!
context_click() 右击
double_click() 双击
drag_and_drop() 拖动
move_to_element() 鼠标悬停
'''
'''
from selenium import webdriver
#引入ActionChains类
from selenium.webdriver.common.action_chains import ActionChains
#使用方法
brower = webdriver.Firefox()
brower.get("http://www.baidu.com")
#定位到需要右击的元素并赋值给rigth_click
right_click = brower.find_element_by_id("xx")
#对定位到的元素进行右击操作。
ActionChains(brower).context_click(right_click).perform()
'''
#以下是代码解释:
'''
from selenium.webdriver import ActionChains
对于 ActionChains 类下面的方法,在使用之前需要先将模块导入。
ActionChains(driver)
调用 ActionChains()方法,在使用将浏览器驱动 driver 作为参数传入。
context_click(right_click)
context_click()方法用于模拟鼠标右键事件,在调用时需要传入右键的元素。
perform()
执行所有 ActionChains 中存储的行为,可以理解成是对整个操作事件的提交动作。
'''
#鼠标悬停
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
brower = webdriver.Firefox()
brower.get("http://www.baidu.com")
#brower.maximize_window()
move_mouse = brower.find_element_by_xpath(".//*[@id='u1']/a[8]")
ActionChains(brower).move_to_element(move_mouse).perform()
brower.find_element_by_name("tj_nuomi").click()
'''
除此之外,另外几个的用法是一样的。
'''
'''
Created on 2015-5-8
@author: user
简单的鼠标事件以及使用方法!!!
context_click() 右击
double_click() 双击
drag_and_drop() 拖动
move_to_element() 鼠标悬停
'''
'''
from selenium import webdriver
#引入ActionChains类
from selenium.webdriver.common.action_chains import ActionChains
#使用方法
brower = webdriver.Firefox()
brower.get("http://www.baidu.com")
#定位到需要右击的元素并赋值给rigth_click
right_click = brower.find_element_by_id("xx")
#对定位到的元素进行右击操作。
ActionChains(brower).context_click(right_click).perform()
'''
#以下是代码解释:
'''
from selenium.webdriver import ActionChains
对于 ActionChains 类下面的方法,在使用之前需要先将模块导入。
ActionChains(driver)
调用 ActionChains()方法,在使用将浏览器驱动 driver 作为参数传入。
context_click(right_click)
context_click()方法用于模拟鼠标右键事件,在调用时需要传入右键的元素。
perform()
执行所有 ActionChains 中存储的行为,可以理解成是对整个操作事件的提交动作。
'''
#鼠标悬停
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
brower = webdriver.Firefox()
brower.get("http://www.baidu.com")
#brower.maximize_window()
move_mouse = brower.find_element_by_xpath(".//*[@id='u1']/a[8]")
ActionChains(brower).move_to_element(move_mouse).perform()
brower.find_element_by_name("tj_nuomi").click()
'''
除此之外,另外几个的用法是一样的。
'''
0 0
- selenium Python自动化测试(基本的鼠标事件)
- selenium Python自动化测试(基本的键盘事件)
- selenium+python自动化测试(四)--鼠标和键盘事件
- 初学者的Selenium自动化测试指南,基于Python(四)——常用鼠标事件
- selenium Python自动化测试(基本的验证方式)
- 基于《Selenium 2自动化测试实战》的学习笔记(8)—— 鼠标事件
- selenium+python—实现基本自动化测试
- 初学者的Selenium自动化测试指南,基于Python(五)——常用键盘事件
- selenium自动化之鼠标事件
- 6、Selenium + Python 实现 UI 自动化测试-鼠标操作
- Python-Selenium2做Web自动化测试(5)-对象事件的操作(鼠标操作、键盘操作)
- Selenium+Python 鼠标事件
- python + selenium 自动化测试
- selenium + python 自动化测试
- Python自动化测试-Selenium
- selenium + python 自动化测试
- 基于Python+selenium的自动化测试基础
- 自动化测试(python+selenium)入门(一)
- Django新版添加app提示模块不存在解决方法 INSTALLED_APPS 错误
- ACM数学
- MyEclipse + Maven 整合时一些奇葩问题的解决办法
- Python WSGI 介绍
- ubuntu eclipse打开help-》install new software 等选项没反应的解决办法
- selenium Python自动化测试(基本的鼠标事件)
- 数论题目分类
- 9、数据库初学习,基本安装以及配置、使用方法
- Redhat下安装启动Hadoop
- POJ图论题目
- selenium Python自动化测试(基本的键盘事件)
- Eclipse注释模板
- Unity3D研究院之Machine动画脚本自动生成AnimatorController(七十一)
- Unity游戏开发的数学与物理 2 ( 通过键盘控制物体的运动 )