#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模拟鼠标悬停操作的更多相关文章

  1. selenium webdriver(4)---模拟鼠标键盘操作

    webdriver提供Actions来模拟鼠标悬浮.拖拽和键盘输入等操作,详细代码见org.openqa.selenium.interactions.Actions.本文通过几个实例来说明Action ...

  2. selenium - webdriver - ActionChains类(鼠标操作)

    ActionChains 类提供了鼠标操作的常用方法: perform(): 执行所有 ActionChains 中存储的行为: context_click(): 右击: double_click() ...

  3. Selenium WebDriver中一些鼠标和键盘事件的使用

    转自:http://www.ithov.com/linux/133271.shtml 在使用 Selenium WebDriver 做自动化测试的时候,会经常模拟鼠标和键盘的一些行为.比如使用鼠标单击 ...

  4. 转:总结Selenium WebDriver中一些鼠标和键盘事件的使用

    在使用 Selenium WebDriver 做自动化测试的时候,会经常模拟鼠标和键盘的一些行为.比如使用鼠标单击.双击.右击.拖拽等动作:或者键盘输入.快捷键使用.组合键使用等模拟键盘的操作.在 W ...

  5. 总结Selenium WebDriver中一些鼠标和键盘事件的使用

    在使用 Selenium WebDriver 做自动化测试的时候,会经常模拟鼠标和键盘的一些行为.比如使用鼠标单击.双击.右击.拖拽等动作:或者键盘输入.快捷键使用.组合键使用等模拟键盘的操作.在 W ...

  6. python模拟鼠标拖动操作的方法

    本文实例讲述了python模拟鼠标拖动操作的方法.分享给大家供大家参考.具体如下: pdf中的书签只有页码,准备把现有书签拖到一个目录中,然后添加自己页签.重复的拖动工作实在无趣,还是让程序帮我实现吧 ...

  7. 多测师讲解自动化测试 _RF模拟鼠标悬停_高级讲师肖sir

    test19 Open Browser https://www.ctrip.com/?sid=155952&allianceid=4897&ouid=index gc Maximize ...

  8. selenium webdriver从安装到使用(python语言),显示等待和隐性等待用法,切换窗口或者frame,弹框处理,下拉菜单处理,模拟鼠标键盘操作等

    selenium的用法 selenium2.0主要包含selenium IDE 和selenium webDriver,IDE有点类似QTP和LoadRunner的录制功能,就是firefox浏览器的 ...

  9. selenium webdriver模拟鼠标键盘操作

    在测试使用Selenium webdriver测试WEB系统的时候,用到了模拟鼠标.键盘的一些输入操作. 1.鼠标的左键点击.双击.拖拽.右键点击等: 2.键盘的回车.回退.空格.ctrl.alt.s ...

随机推荐

  1. JavaScript笔记2

    1.浮点数在运算过程中会产生误差,因为计算机无法精确表示无限循环小数. 要比较两个浮点数是否相等,只能计算它们之差的绝对值,看是否小于某个阈值(某个可接受的范围):Math.abs(1 / 3 - ( ...

  2. Ubuntu 11.04源

    ##国内源#这个北京交通大学的源也挺不错的,我们首选这个,速度很不错deb http://mirror.bjtu.edu.cn/ubuntu/ narwhal multiversedeb http:/ ...

  3. Android tess_two Android图片文字识别

    文字识别一般都用的tesseract-ocr. GitHub:https://github.com/tesseract-ocr/tesseract 而Android对应的比较推荐的有个tess-two ...

  4. httpHelper请求辅助类

    #import <Foundation/Foundation.h> #import "AFNetworking.h" @interface AFHttpClient : ...

  5. selenium +python之多线程与多进程应用于自动化测试

    多线程与多进程与自动化测试用例结合起来执行,从而节省测试用例的总体运行时间. 多线程执行测试测试用例 以百度搜索为例,通过不同的浏览器来启动不同的线程. from selenium import we ...

  6. Netweaver和CloudFoundry是如何运行Web应用的?

    Netweaver 在Jerry的微信公众号文章SAP Fiori应用的三种部署方式里提到SAP Fiori应用以BSP应用的方式部署在ABAP Front-End Server上.那么这些BSP应用 ...

  7. HTML之基本语法(表单)

    一.表单的基本介绍 表单:就是互联网上用于收集用户信息的一种结构,在HTML当中事先定义好了一种标签来完成此事,标签名称为form,它是一个双标签<form action="" ...

  8. 第三章 DOM的基本

    节点分为不同的类型:元素节点.属性节点和文本节点 getElementById()方法 这个方法将返回一个与那个有着给定id属性值的元素节点相对应的对象.注意大小写.该方法只有一个参数.这个参数也就是 ...

  9. VA助手添加扩展文件后缀名

    Allow C/C++ files with a non-standard extension Follow these steps to make Visual Assist consider as ...

  10. Stream great concerts wherever you are

    This time of year, we take stock of what we're thankful for — and above all else, we’re thankful for ...