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 ...
随机推荐
- 280. Wiggle Sort
题目: Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] ...
- Mybatis SqlSessionTemplate 源码解析
As you may already know, to use MyBatis with Spring you need at least an SqlSessionFactory and at le ...
- OpenGL基础知识
基本概念 透视(Perspective)变换(Transformation)投影矩阵(Projection Matrix):用于将3D坐标转换为2D屏幕坐标光栅化(Rasterization): 实际 ...
- USACO Section 3.2: Stringsobits
这题看了网上的答案的.还是很巧妙的 /* ID: yingzho1 LANG: C++ TASK: kimbits */ #include <iostream> #include < ...
- 【Cocos2d实例教程一】xcode5下Cocos2d环境的搭建
(转载请注明出处:http://blog.csdn.net/buptgshengod) 第一步,现在要安装集成环境xcode5,安装xcode5需要系统至少是os x 10.8.5. 第二步,下载co ...
- python中的类简单讲解
类似其它的语言, Python 中的函数使用小括号( () )调用.函数在调用之前必须先定义.如果函数中没有 return 语句, 就会自动返回 None 对象. Python 是通过引用调 ...
- 18.allegro区域约束规则设置
一.线宽和线间距 --- ---------------- 然后再电路板上创建一个区域 ----- ---- --- ---- ------------------------------
- Docker入门命令
Edit Docker入门命令 # 安装镜像sudo docker pull ubuntu:12.04# 镜像列表sudo docker images# 运行镜像sudo docker run -t ...
- 51nod1052 最大M子段和
dp优化我总是不太熟练.这一次首先我写了O(n4)->O(n3)->O(n2).一步步的优化过来.yyl好像用的是单调队列优化dp我看不懂他的代码... O(n4) #include< ...
- DOM应用
父级.removeChild(子节点);父级.appendChild(子节点);父级.insertBefore(子节点, 在谁之前); 创建元素: <script> window.onlo ...