Selenium WebDriver-下拉框断言
#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()
Selenium WebDriver-下拉框断言的更多相关文章
- 11 Python+selenium对下拉框(select)进行处理
[环境信息] Python3.4+IE+windows2008 [Select下拉框处理] 1.对于如图1的下拉框,可以用selenium自带的Select类进行选择. 2.定位示例: from se ...
- 自动化测试基础篇--Selenium select下拉框
摘自https://www.cnblogs.com/sanzangTst/p/7681523.html 一.什么是下拉框 下拉框是多项选择项,选择其中一种,类似下面(以百度搜索设置为例) 源代码如下所 ...
- 自动化测试-11.selenium的下拉框处理类Select
前言 最近由于工作原因,更新慢了一点,今天终于抽出一点时间给大家继续更新selenium系列,学习的脚本不能停止,希望小伙伴能多多支持. 本篇以百度设置下拉选项框为案例,详细介绍select下拉框相关 ...
- Python+Selenium学习--下拉框处理
场景 下拉框也是web 页面上非常常见的功能,webdriver 对于一般的下拉框处理起来也相当简单,要想定位下拉框中的内容,首先需要定位到下拉框:这样的二次定位 下拉框一般有以下两种方式: 鼠标移上 ...
- python selenium --处理下拉框
下拉框是我们最常见的一种页面元素,对于一般的元素,我们只需要一次就定位,但下拉框里的内容需要进行两次定位,先定位到下拉框,再定位到下拉框内里的选项. drop_down.html <html&g ...
- webdriver下拉框中选择option的方法提醒
select这个标签比较特殊 下面的option不能用点击下拉框,再点击选中这种方法 前端代码: <html> <body> <select id="Shipp ...
- selenium Select下拉框
先来认识一下下拉框,以百度的“高级设置”为例 介绍两种方法来处理下拉框:使用click事件,使用Select方法 使用click事件 上述下拉框的源代码如下: 虽然我们可以在html源文件中看到sel ...
- Selenium+java - 下拉框处理
常见下拉框也分两种:一种是标准控件和非标准控件(一般为前端开发人员自己封装的下拉框),本篇文章中将重点讲解标准下拉框操作. 1.Select提供了三种选择某一项的方法 select.selectByI ...
- Selenium:下拉框处理(Select模块)
在UI自动化测试过程中,经常会遇到一些下拉框,如果我们基于Webdriver操作的话就需要click两次,而且很容易出现问题,实际上Selenium给我们提供了专门的Select(下拉框处理模块). ...
- 多测师讲解selenium _下拉框的定位_高级讲师肖sir
from selenium import webdriver from selenium.webdriver.support.ui import Select#导入类from time import ...
随机推荐
- MySQL获取某个时间范围内的数据 TO_DAYS(date)函数
1.利用to_days函数查询今天的数据: select * from 表名 where to_days(时间字段名) = to_days(now()); to_days函数:返回从0000年(公元1 ...
- 安装ubuntu出现BUG soft lockup的解决方法(16.04 14.04)
对于16.04而言,当时用的是UtrISO 安装的,导致安装过程用会出现 “not a com32r image” 的错误,解决方法见上文的: boot: live 华硕Z9主板安装16.04以上系统 ...
- pytest+allure2+jenkins环境部署
1.pycharm安装allure-pytest 2.jenkins -> 系统管理 -> 插件管理 -> 可选插件中过滤Allure,勾选对应插件安装 如下图: 3.安装完插件后 ...
- CentOS7.2上搭建httpbin环境
CentOS7上搭建httpbin环境 1.安装python31)安装python3.6可能使用的依赖yum -y install openssl-devel bzip2-devel expat-de ...
- python之元组,列表和字典的区别
Python语言包含6种内建的序列,其中,有两种主要的类型:列表和元组. 列表是可以修改的,而元组不可以,如果要添加或者删除某些元素,就只能用列表,为了限制某些元素,就会用到元组.一般来说,列表可以替 ...
- 挂sqlserver计划,系统自动分配拣货任务
USE [P2WMS_WH43] GO /****** Object: StoredProcedure [dbo].[sp_fru_CalcAllocatePickData] Script Date: ...
- 【exFat】利用命令提示符在windows 7 及 windows server 2008 r2 中将卷(分区)格式化为exFAT
步骤 运行cmd.exe: 查看磁盘信息.输入diskpart并回车: 选择磁盘.输入select disk 0(“0”代表要选择的磁盘号)并回车: 查看所选硬盘的分区.输入list partitio ...
- 【UML】对象图Object diagram(转)
http://blog.csdn.net/sds15732622190/article/details/48894751 前言 今天要说的是UML中的对象图.他与类图,合作图都有关系,是类图的实例化. ...
- ios常见错误之 Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?
Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the desi ...
- Opencascade术语笔记。
1. chamfer 倒角 vs fillet 圆角: 2.boolean operatiron(布尔操作): common(相加),fuse(相交),cut(相减): 3.depressions( ...