首页 技术 正文
技术 2022年11月18日
0 收藏 498 点赞 4,571 浏览 925 个字
#encoding=utf-8
import unittest
import time
import chardet
from selenium import webdriverclass 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()
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,077
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,552
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,400
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,813
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,896