#encoding=utf-8
import unittest
import time
import chardet
from selenium import webdriver 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_checkSelectText(self):
url = "http://127.0.0.1/test_select.html"
# 访问自定义的html网页
self.driver.get(url)
# 导入Select模块
from selenium.webdriver.support.ui import Select
# 使用xpath定位方式获取select页面元素对象
select_element = Select(self.driver.find_element_by_xpath("//select"))
# 获取所有选择项的页面元素对象
actual_options = select_element.options
# 声明一个list对象,存储下拉列表中所期望出现的文字内容
expect_optionsList = [u"桃子",u"西瓜",u"橘子",u"猕猴桃",u"山楂",u"荔枝"]
# 使用Python内置map()函数获取页面中下拉列表展示的选项内容组成的列表对象
actual_optionsList = map(lambda option: option.text, actual_options)
# 断言期望列表对象和实际列表对象是否完全一致
self.assertListEqual(expect_optionsList, actual_optionsList) def tearDown(self):
# 退出IE浏览器
self.driver.quit() if __name__ == '__main__':
unittest.main()

最新文章

  1. strtol 函数用法
  2. c++使用stdint.h和inttypes.h
  3. [原创]cocos2d-x研习录-第二阶 概念类之摄相机类(CCCamera)
  4. js 默认行为取消
  5. jQuery 写的插件图片上下切换幻灯效果
  6. Python学习总结11:获取当前运行类名和函数名
  7. mysql 错误- 磁盘空间不足,
  8. HDU-1018(简单数学)
  9. C#中使用REDIS
  10. [置顶] WPF数据修改demo
  11. There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
  12. 设计模式——单例设计模式(C++实现)
  13. Windows的GDI映射方式,逻辑坐标,设备坐标的理解
  14. JavaScript -- 时光流逝(三):js中的 String 对象的方法
  15. 【CF1141G】Privatization of Roads in Treeland
  16. Shell 终端ANSI控制码
  17. Beta冲刺 (3/7)
  18. vs2017 C4996 错误
  19. .Net机试题——编写一个BS架构的多层表结构的信息管理模块
  20. mysql常用的一些修改命令

热门文章

  1. vue-cli3项目中解决动态引入图片img404的问题
  2. [拾零]C语言的数组指针
  3. linux命令行—《命令行快速入门》
  4. Android自定义组件系列【17】——教你如何高仿微信录音Toast
  5. MFC CDialog/CDialogEx DoModal ALT
  6. Objective-C Inheritance
  7. PHP_RAW_POST_DATA特性
  8. svn与git区别简介,git分支操作在mac客户端soureTree和使用命令行如何实现
  9. javaSe-线程2
  10. 洛谷 P3143 [USACO16OPEN]钻石收藏家Diamond Collector