#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-下拉框断言的更多相关文章

  1. 11 Python+selenium对下拉框(select)进行处理

    [环境信息] Python3.4+IE+windows2008 [Select下拉框处理] 1.对于如图1的下拉框,可以用selenium自带的Select类进行选择. 2.定位示例: from se ...

  2. 自动化测试基础篇--Selenium select下拉框

    摘自https://www.cnblogs.com/sanzangTst/p/7681523.html 一.什么是下拉框 下拉框是多项选择项,选择其中一种,类似下面(以百度搜索设置为例) 源代码如下所 ...

  3. 自动化测试-11.selenium的下拉框处理类Select

    前言 最近由于工作原因,更新慢了一点,今天终于抽出一点时间给大家继续更新selenium系列,学习的脚本不能停止,希望小伙伴能多多支持. 本篇以百度设置下拉选项框为案例,详细介绍select下拉框相关 ...

  4. Python+Selenium学习--下拉框处理

    场景 下拉框也是web 页面上非常常见的功能,webdriver 对于一般的下拉框处理起来也相当简单,要想定位下拉框中的内容,首先需要定位到下拉框:这样的二次定位 下拉框一般有以下两种方式: 鼠标移上 ...

  5. python selenium --处理下拉框

    下拉框是我们最常见的一种页面元素,对于一般的元素,我们只需要一次就定位,但下拉框里的内容需要进行两次定位,先定位到下拉框,再定位到下拉框内里的选项. drop_down.html <html&g ...

  6. webdriver下拉框中选择option的方法提醒

    select这个标签比较特殊 下面的option不能用点击下拉框,再点击选中这种方法 前端代码: <html> <body> <select id="Shipp ...

  7. selenium Select下拉框

    先来认识一下下拉框,以百度的“高级设置”为例 介绍两种方法来处理下拉框:使用click事件,使用Select方法 使用click事件 上述下拉框的源代码如下: 虽然我们可以在html源文件中看到sel ...

  8. Selenium+java - 下拉框处理

    常见下拉框也分两种:一种是标准控件和非标准控件(一般为前端开发人员自己封装的下拉框),本篇文章中将重点讲解标准下拉框操作. 1.Select提供了三种选择某一项的方法 select.selectByI ...

  9. Selenium:下拉框处理(Select模块)

    在UI自动化测试过程中,经常会遇到一些下拉框,如果我们基于Webdriver操作的话就需要click两次,而且很容易出现问题,实际上Selenium给我们提供了专门的Select(下拉框处理模块). ...

  10. 多测师讲解selenium _下拉框的定位_高级讲师肖sir

    from selenium import webdriver from selenium.webdriver.support.ui import Select#导入类from time import ...

随机推荐

  1. Mysql有什么办法批量去掉某个字段字符中的空格

    Mysql有什么办法批量去掉某个字段字符中的空格?不仅是字符串前后的空格,还包含字符串中间的空格,答案是 replace,使用mysql自带的 replace 函数,另外还有个 trim 函数.   ...

  2. Git 连接远程仓库Github

    创建SSH Key. 在用户主目录下,看看有没有.ssh目录,如果有,再看看这个目录下有没有id_rsa和id_rsa.pub这两个文件,如果已经有了,可直接跳到下一步. 如果没有,打开Shell(W ...

  3. calibre电子书管理软件

    软件介绍: Calibre 是电子书管理软件,支持 Amazon.Apple.Bookeen.Ectaco.Endless Ideas.Google/HTC.Hanlin Song 设备及格式,功能十 ...

  4. 理解 JavaScript 的 async/await

    随着 Node 7 的发布,越来越多的人开始研究据说是异步编程终级解决方案的 async/await.我第一次看到这组关键字并不是在 JavaScript 语言里,而是在 c# 5.0 的语法中.C# ...

  5. Python3+Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )

    !/usr/bin/env python -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )'''from selenium im ...

  6. Linux Shell流程例子

    #!/bin/bash read -p "input a dight:"echo $REPLY DATE=`date`echo "DATE is ${DATE}" ...

  7. COGS 13. 运输问题4

    ★★☆   输入文件:maxflowd.in   输出文件:maxflowd.out   简单对比时间限制:1 s   内存限制:128 MB [问题描述]     一个工厂每天生产若干商品,需运输到 ...

  8. @Param注解在dao层的使用

    有时在前台用ajax传过来许多参数,不知道在mybatis如何封装,就要用到@Param注解了,这时就不需要在映射文件写传入参数了,这种方法虽然比较取巧,但还是很实用的,如下图:

  9. 【0624课外作业】将一个double类型的小数,四舍五入保留两位小数

    package com.work0624; /** * 课外作业 *将一个double类型的小数,四舍五入保留两位小数 * @author L * */ import java.util.Scanne ...

  10. java中插入myslq的datetime类型的

    java.util.Date d = new java.util.Date(); Timestamp tt=new Timestamp(d.getTime()); ps.setTimestamp(4, ...