Selenium2Library系列 keywords 之 _SelectElementKeywords 之 select_from_list(self, locator, *items)
def select_from_list(self, locator, *items):
"""Selects `*items` from list identified by `locator` If more than one value is given for a single-selection list, the last
value will be selected. If the target list is a multi-selection list,
and `*items` is an empty list, all values of the list will be selected. *items try to select by value then by label. It's faster to use 'by index/value/label' functions. An exception is raised for a single-selection list if the last
value does not exist in the list and a warning for all other non-
existing items. For a multi-selection list, an exception is raised
for any and all non-existing values. 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.
"""
non_existing_items = [] items_str = items and "option(s) '%s'" % ", ".join(items) or "all options"
self._info("Selecting %s from list '%s'." % (items_str, locator)) select = self._get_select_list(locator) if not items:
for i in range(len(select.options)):
select.select_by_index(i)
return for item in items:
try:
select.select_by_value(item)
except:
try:
select.select_by_visible_text(item)
except:
non_existing_items = non_existing_items + [item]
continue if any(non_existing_items):
if select.is_multiple:
raise ValueError("Options '%s' not in list '%s'." % (", ".join(non_existing_items), locator))
else:
if any (non_existing_items[:-1]):
items_str = non_existing_items[:-1] and "Option(s) '%s'" % ", ".join(non_existing_items[:-1])
self._warn("%s not found within list '%s'." % (items_str, locator))
if items and items[-1] in non_existing_items:
raise ValueError("Option '%s' not in list '%s'." % (items[-1], locator))
方法名:select_from_list(self, locator, *items)
相似方法:
公共方法 选中所传入items,如果给了多个值,并且是single-selection list,则最后一值会被选中;如果是 multi-selection list,并且items为空,则所有options都会被选中
接收参数:locator,*items(labels/values)
26行:使用_get_select_list(self, locator)方法,返回Select对象
Selenium2Library系列 keywords 之 _SelectElementKeywords 之 select_from_list(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 之 list_selection_should_be(self, locator, *items)
def list_selection_should_be(self, locator, *items): """Verifies the selection of sel ...
- 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 ...
随机推荐
- iOS 库文件制作
一.静态库和动态库的介绍 一.什么是库? 库是共享程序代码的方式,一般分为静态库和动态库. 二.静态库与动态库的区别? 静态库:链接时完整地拷贝至可执行文件中,被多次使用就有多份冗余拷贝. 动态库:链 ...
- C语言:几种字符输入函数的区别
几种字符输入函数的区别: 1.getche()函数:用于从键盘读入一个字符并显示,然后直接执行下一条语 句. 2.getch()函数:用于从键盘中读入一个字符,但不显示在屏幕上, 然后 ...
- Action的执行
异步Action的定义 两种异步Action方法的定义 xxxAsync/xxxCompleted 这种形式的异步只能定义在实现了AsyncController的Controller中.针对Task的 ...
- Data Flow ->> Fuzzy Lookup & Fuzzy Grouping
这两个任务的作用是数据清洗(Data Cleansing). Fuzzy Lookup通过引用另外一张数据库表或者索引来进行相似值匹配.这种组件对于标准化和查找可能错误的客户端数据非常有用.例如像地址 ...
- Socket基础编程
地址结构sockaddr_in 其中包含:IP地址,端口号,协议族推荐使用sockaddr_in,而不建议使用sockaddrsockaddr_in与sockaddr是等价的,但sockaddr_in ...
- OpenCV4Android——No implementation found for native Lorg/opencv/core/Mat;.n_Mat ()J
ok 12-17 08:13:10.461: W/dalvikvm(540): No implementation found for native Lorg/opencv/core/Mat;.n_M ...
- lib-qqwry v1.0 发布 nodejs解析纯真IP库(qqwry.dat)
lib-qqwry是当初学习node时用来练手的一个模块,用来解析纯真IP库的 现在发一个v1.0版本弥补我当时稚嫩的代码. 意外收获是,整理代码后发现,相比v0.x版本 急速模式下的效率提升大概20 ...
- PHP 增删改查 import!!
主页面 <h1>主页面family</h1> <table width="100%" border="1px" cellpaddi ...
- NDK(10)Android.mk各属性简介,Android.mk 常用模板
参考 : http://blog.csdn.net/hudashi/article/details/7059006 本文内容: Android.mk简介, 各属性表, 常用Android.mk模板 1 ...
- cut命令如何截取以空格隔开的字段
你的文件分隔符恐怕不止一个空格(一定的who生成的): 用awk: awk '{print $2}' file 一定要用cut的话: cat file|tr -s ' '|cut -d' ' -f2 ...