#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()

最新文章

  1. WPF实现TextBox水印效果
  2. jQuery Easy UI 开发笔记
  3. IOS开发/iphone开发多线程
  4. linux命令别名的使用
  5. jquery的$.ajax async使用详解
  6. IOS上传图片
  7. Android 仿微信小视频录制
  8. Nginx的代理和反向代理
  9. Flask+Mysql搭建网站之安装Mysql
  10. hdoj分类
  11. AbstractHandlerMapping解读
  12. entity framework core在独立类库下执行迁移操作
  13. Android Multimedia框架总结(四)MediaPlayer中从Java层到C++层类关系及prepare及之后其他过程
  14. 从零开始学 Web 之 DOM(七)事件冒泡
  15. java之面向对象的基础知识
  16. P499 usebrass2
  17. 使用maven构建一个web项目
  18. 【leetcode】58-LengthofLastWord
  19. node.js second day
  20. 【python学习-4】可复用函数与模块

热门文章

  1. Python3基础02(列表和字符串处理)
  2. telegraf1.8+influxdb1.6+grafana5.2 环境搭建 结合JMeter3.2
  3. 使用poi或jxl,通过java读写xls、xlsx文档
  4. python 之 re 模块
  5. android测试开发环境搭建
  6. 洛谷 P2014 选课
  7. 2d游戏中求出一个向量的两个垂直向量
  8. C#MySQL增删改查
  9. Convert HTML Entities-freecodecamp算法题目
  10. linux优化之优化开机自启动服务