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 ...
随机推荐
- web常见几种处理图标方法
方法一: 用background制作小图标 像这样,拿到设计稿后把所有的图标放在一张图片上,利用background-position.width.height来控制图标的位置及大小. 代码: .ic ...
- Jquery ajax中表单提交被拦截的问题处理方法
在实际开发项目中,由于要做支付宝的批量退款处理,需要用到ajax中去提交表单数据,项目截图如下: 由于在第二张截图“确认退款”那里需要异步ajax提交数据到服务器处理信息,处理成功后将返回的数据装载到 ...
- Game Engine Architecture
- Kippo-Failed to load application: 'module' object has no attribute 'IPluggableAuthenticationModules'
Kippo-Failed to load application: 'module' object has no attribute 'IPluggableAuthenticationModules' ...
- 四、filter和find函数的区别
filter(): filter函数会返回data中为true那项的数组(即查询符合条件的数据) eg:data.filter((f)=>{ if(f[name]===item[name]){ ...
- 【转】JavaScript 节点操作 以及DOMDocument属性和方法
最近发现DOMDocument对象很重要,还有XMLHTTP也很重要 注意大小写一定不能弄错. 属性: 1Attributes 存储节点的属性列表(只读) 2childNodes 存储节点的子节点列表 ...
- IEDA的安装与破解
百度搜索IDEA 进入官网下载 https://www.jetbrains.com/idea/download/#section=windows 2.下载好双击即可 3. 完成破解
- Google「Game Builder」:不懂编程,也能开发 3D 游戏
简评: 之前微软曾推出过「Kodu Game Lab」,它可以让完全没有编程经验的人通过简单的步骤打造属于自己的游戏.无独有偶,Google 最近在 Steam 也推出了类似的程序「Game Buil ...
- lua拷贝二进制文件的方法
使用lua拷贝二进制文件相比文本文件复杂一点,方法如下 function copyFunc(targetPath,sourcePath) local rf = io.open(sourcePath,& ...
- 【转】再谈 最速下降法/梯度法/Steepest Descent
转载请注明出处:http://www.codelast.com/ 最速下降法(又称梯度法,或Steepest Descent),是无约束最优化领域中最简单的算法,单独就这种算法来看,属于早就“过时”了 ...