Selenium2Library系列 keywords 之 _SelectElementKeywords 之 list_selection_should_be(self, locator, *items)
- def list_selection_should_be(self, locator, *items):
- """Verifies the selection of select list identified by `locator` is exactly `*items`.
- If you want to test that no option is selected, simply give no `items`.
- Select list keywords work on both lists and combo boxes. Key attributes for
- select lists are `id` and `name`. See `introduction` for details about
- locating elements.
- """
- items_str = items and "option(s) [ %s ]" % " | ".join(items) or "no options"
- self._info("Verifying list '%s' has %s selected." % (locator, items_str))
- items = list(items)
- self.page_should_contain_list(locator)
- select, options = self._get_select_list_options_selected(locator)
- if not items and len(options) == 0:
- return
- selected_values = self._get_values_for_options(options)
- selected_labels = self._get_labels_for_options(options)
- err = "List '%s' should have had selection [ %s ] but it was [ %s ]" \
- % (locator, ' | '.join(items), ' | '.join(selected_labels))
- for item in items:
- if item not in selected_values + selected_labels:
- raise AssertionError(err)
- for selected_value, selected_label in zip(selected_values, selected_labels):
- if selected_value not in items and selected_label not in items:
- raise AssertionError(err)
方法名:list_selection_should_be(self, locator, *items)
相似方法:
公共方法 验证指定labels或values的选项应该被选中
接收参数:locator,*items(labels/values)
13行:使用page_should_contain_list(self, locator, message='', loglevel='INFO')方法,验证select list 存在于当前页面
14行:使用_get_select_list_options_selected(self, locator)方法返回Select 元素对象和选中options数组
17行:使用_get_values_for_options(self, options)方法返回选中options的values数组
18行:使用_get_labels_for_options(self, options)返回选中options的labels数组
20、21行: 遍历所传入的items,判断item是否为选中项
24、25行: 遍历当前选中项的value和label,如果不在传入items中存在则报错
使用:
输出结果:
- FAIL : List 'id=creOutTime' should have had selection [ 0 | 1 ] but it was [ 无逾期 | 无记录(征信空白) | 贷款或贷记卡当前逾期金额>=300元 ]
Selenium2Library系列 keywords 之 _SelectElementKeywords 之 list_selection_should_be(self, locator, *items)的更多相关文章
- Selenium2Library系列 keywords 之 _SelectElementKeywords 之 unselect_from_list(self, locator, *items)
def unselect_from_list(self, locator, *items): """Unselects given values from select ...
- Selenium2Library系列 keywords 之 _SelectElementKeywords 之 select_from_list(self, locator, *items)
def select_from_list(self, locator, *items): """Selects `*items` from list identified ...
- Selenium2Library系列 keywords 之 _SelectElementKeywords 之 unselect_from_list_by_label(self, locator, *labels)
def unselect_from_list_by_label(self, locator, *labels): """Unselects `*labels` from ...
- Selenium2Library系列 keywords 之 _SelectElementKeywords 之 unselect_from_list_by_value(self, locator, *values)
def unselect_from_list_by_value(self, locator, *values): """Unselects `*values` from ...
- Selenium2Library系列 keywords 之 _SelectElementKeywords 之 unselect_from_list_by_index(self, locator, *indexes)
def unselect_from_list_by_index(self, locator, *indexes): """Unselects `*indexes` fro ...
- Selenium2Library系列 keywords 之 _SelectElementKeywords 之 select_from_list_by_label(self, locator, *labels)
def select_from_list_by_label(self, locator, *labels): """Selects `*labels` from list ...
- Selenium2Library系列 keywords 之 _SelectElementKeywords 之 select_from_list_by_value(self, locator, *values)
def select_from_list_by_value(self, locator, *values): """Selects `*values` from list ...
- Selenium2Library系列 keywords 之 _SelectElementKeywords 之 list_should_have_no_selections(self, locator)
def list_should_have_no_selections(self, locator): """Verifies select list identified ...
- Selenium2Library系列 keywords 之 _SelectElementKeywords 之 get_selected_list_values(self, locator)
def get_selected_list_values(self, locator): """Returns the values of selected elemen ...
随机推荐
- VCL ActiveX 播放视频
播放网络视频 string[] options = new string[] { ":sout=#duplicate{dst=display} :no-overlay" }; st ...
- TCL语言笔记:TCL基础语法
一.什么是TCL Tcl 全称是 Tool command Language.它是一个基于字符串的命令语言,基础结构和语法非常简单,易于学习和掌握. Tcl 语言是一个解释性语言,所谓解释性是指不象其 ...
- IDEA查找功能小结
查找类:Ctrl + N 支持模糊查询
- set集合_定长
//set集合的操作 //便利初始化函数 NSSet *set1 = [[NSSet alloc] initWithObjects:@"aa", @&q ...
- eclipse Juno Indigo Helios Galileo这几种版本的意思(转)
Galileo Ganymede Europa 这些名字代表eclipse不同的版本 2001年11月7日 ,Eclipse 1.0发布 半年之后,2002年6月27日Eclipse进入了2.0 ...
- Vim的tagbar插件
1.tagbar针对当前文件,调用ctags来生成结果,并抓取其结果,像下边这样的 ctags -f - --format=2 --excmd=pattern --extra= --fields=nk ...
- nyoj-291 互素数个数 欧拉函数
LK的数学题 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 LK最近遇到一个问题,需要你帮她一下.一个整数n,求[1,n)中,和n互素的数的个数. 输入 多组测 ...
- 函数buf_page_create
/********************************************************************//** Initializes a page to the ...
- bzoj3261: 最大异或和
可持久化trie.又是%%%Xs酱... #include<cstdio> #include<cstring> #include<iostream> #includ ...
- Linux LiveCD 的制作
Knoppix,只需一张光盘, 就能够让我们在任何场所,随心所欲地使用 Linux1, 打破了操作系统只能先安装再使用的传统概念. Knoppix 最初的设计用途是教学,但由于这项技术很受欢迎,使得 ...