Selenium WebDriver- actionchians模拟鼠标悬停操作
#encoding=utf-8
import unittest
import time
from selenium import webdriver
from selenium.webdriver import ActionChains class VisitSogouByIE(unittest.TestCase): def setUp(self):
#启动IE浏览器
#self.driver = webdriver.Firefox(executable_path = "e:\\geckodriver")
self.driver = webdriver.Ie(executable_path = "e:\\IEDriverServer") def test_roverOnElement(self):
url = "http://127.0.0.1/test_mouse_hover.html"
# 访问自定义的html网页
self.driver.get(url)
# 找到页面上第一个链接元素
link1 = self.driver.find_element_by_partial_link_text(u"指过来1")
# 找到页面上第二个链接元素
link2 = self.driver.find_element_by_partial_link_text(u"指过来2")
# 找到页面上的p元素
p = self.driver.find_element_by_xpath("//p")
print link1.text, link2.text
# 导入需要的Python包
from selenium.webdriver import ActionChains
import time
# 将鼠标悬浮到第一个链接元素上
ActionChains(self.driver).move_to_element(link1).perform()
time.sleep(2)
# 将鼠标从第一个链接元素移动到p元素上
ActionChains(self.driver).move_to_element(p).perform()
time.sleep(2)
# 将鼠标悬浮到第二个链接元素上
ActionChains(self.driver).move_to_element(link1).perform()
time.sleep(2)
# 将鼠标从第二个链接元素移动到p元素上
ActionChains(self.driver).move_to_element(p).perform()
time.sleep(2) def tearDown(self):
# 退出IE浏览器
self.driver.quit() if __name__ == '__main__':
unittest.main()
Selenium WebDriver- actionchians模拟鼠标悬停操作的更多相关文章
- selenium webdriver(4)---模拟鼠标键盘操作
webdriver提供Actions来模拟鼠标悬浮.拖拽和键盘输入等操作,详细代码见org.openqa.selenium.interactions.Actions.本文通过几个实例来说明Action ...
- selenium - webdriver - ActionChains类(鼠标操作)
ActionChains 类提供了鼠标操作的常用方法: perform(): 执行所有 ActionChains 中存储的行为: context_click(): 右击: double_click() ...
- Selenium WebDriver中一些鼠标和键盘事件的使用
转自:http://www.ithov.com/linux/133271.shtml 在使用 Selenium WebDriver 做自动化测试的时候,会经常模拟鼠标和键盘的一些行为.比如使用鼠标单击 ...
- 转:总结Selenium WebDriver中一些鼠标和键盘事件的使用
在使用 Selenium WebDriver 做自动化测试的时候,会经常模拟鼠标和键盘的一些行为.比如使用鼠标单击.双击.右击.拖拽等动作:或者键盘输入.快捷键使用.组合键使用等模拟键盘的操作.在 W ...
- 总结Selenium WebDriver中一些鼠标和键盘事件的使用
在使用 Selenium WebDriver 做自动化测试的时候,会经常模拟鼠标和键盘的一些行为.比如使用鼠标单击.双击.右击.拖拽等动作:或者键盘输入.快捷键使用.组合键使用等模拟键盘的操作.在 W ...
- python模拟鼠标拖动操作的方法
本文实例讲述了python模拟鼠标拖动操作的方法.分享给大家供大家参考.具体如下: pdf中的书签只有页码,准备把现有书签拖到一个目录中,然后添加自己页签.重复的拖动工作实在无趣,还是让程序帮我实现吧 ...
- 多测师讲解自动化测试 _RF模拟鼠标悬停_高级讲师肖sir
test19 Open Browser https://www.ctrip.com/?sid=155952&allianceid=4897&ouid=index gc Maximize ...
- selenium webdriver从安装到使用(python语言),显示等待和隐性等待用法,切换窗口或者frame,弹框处理,下拉菜单处理,模拟鼠标键盘操作等
selenium的用法 selenium2.0主要包含selenium IDE 和selenium webDriver,IDE有点类似QTP和LoadRunner的录制功能,就是firefox浏览器的 ...
- selenium webdriver模拟鼠标键盘操作
在测试使用Selenium webdriver测试WEB系统的时候,用到了模拟鼠标.键盘的一些输入操作. 1.鼠标的左键点击.双击.拖拽.右键点击等: 2.键盘的回车.回退.空格.ctrl.alt.s ...
随机推荐
- SQL 事物回滚
转自https://www.cnblogs.com/delphinet/archive/2010/08/17/1801424.html 第一种: declare @iErrorCount ...
- JAVA-WEB总结01
1 工具常用的快捷键 1) Eclipse和MyEclipse,IBM,2001,Java编写,开源,跨平台跨语言 2)Alt+/快速内容提示(自己习惯定义) 3)Ctrl+1快速修补错误 ...
- pod install Pull is not possible because you have unmerged files.
http://stackoverflow.com/questions/21474536/podfile-gives-an-error-on-install A bug was found in lib ...
- windows10下安装TensorFlow Object Detection API
由于官方的文件都是在乌班图和mac系统下的,就上网搜了以下. 按照下边这个博客安装成功了 https://blog.csdn.net/qq_28019591/article/details/82023 ...
- 日常-acm-鸡兔同笼
已知鸡和兔总数量n,总腿数m.输入n和m,依次输出鸡的数量和兔的数量.如果无解,则输出No answer. 样例输入: 14 32 样例输出: 12 2 样例输入: 10 16 样例输出: No an ...
- Processing一些常用技巧
一些常用技巧总结: Tweak模式 快速查找函数用法 显示与输入中文注释 代码快速对齐 批量添加注释符 Tweak模式 Tweak模式是非常有用的功能,自3.0版本后,它就正式整合到Processin ...
- halt, reboot, poweroff - 中止系统运行
SYNOPSIS /sbin/halt [-n] [-w] [-d] [-f] [-i] [-p] /sbin/reboot [-n] [-w] [-d] [-f] [-i] /sbin/powero ...
- Manifest文件
Manifest文件是简单的文本文件,它告知浏览器缓存的内容(或不缓存的内容) Manifest文件可以分为三个部分: 1.CAHCEMANIFEST-在此标题下列出的文件将在首次下载后进行缓存. C ...
- 01_9_Struts用ModelDriven接收参数
01_9_Struts用ModelDriven接收参数 1. 配置struts.xml文件 <package name="user" namespace="/use ...
- 解决cocos simpleAudioEngine播放mp3失败问题
今天用cocos3.x版本实现游戏音乐播放发现一个坑,策划发来的mp3格式音频,用 simpleAudioEngine无法播放, 以为是路径问题,断点调试没找到,然后拷贝了cocos自带的mp3音频文 ...