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 ...
随机推荐
- Struts2笔记——利用token防止表单重复提交
在一些项目中经常会让用户提交表单,当用户点击按钮提交后,如果再次浏览器刷新,这就会造成表单重复提交,若是提交的内容上传至服务器并请求数据库保存,重复提交的表单可能会导致错误,然后跳转到错误界面,这是一 ...
- Struts2笔记——struts常用标签
使用struts标签前,首先要配置struts2架构,然后导入标签库,jsp插入如下语句: <%@taglib uri="/struts-tags" prefix=" ...
- logback与Log4J的区别
原文:http://blog.csdn.net/lwzcjd/article/details/5617200 Logback和log4j是非常相似的,如果你对log4j很熟悉,那对logback很快就 ...
- Android百度地图开发04之POI检索
POI检索 POI~~~ Point of Interest,翻译过来就是“兴趣点”.我们在使用地图的时候,搜索周边的ktv,饭店,或者宾馆的时候,输入关键字,然后地图展示给我们很多个点, 这些点就是 ...
- Javascript获取浏览器窗口大小 获取屏幕,浏览器,网页高度宽度
/******************** * 取窗口滚动条高度 ******************/function getScrollTop(){ var scrollTop=0; ...
- USACO Section 2.4: Bessie Come Home
因为题目给了边的信息,所以比较适用bell-man的方法 /* ID: yingzho1 LANG: C++ TASK: comehome */ #include <iostream> # ...
- c# 计算一个整型数组的平均
一个整型数组的平均: class Program { static void Main(string[] args) { ,,,,,,,,,}; double avg= GetAvg(array); ...
- eclipse中maven项目部署到tomcat
其实maven项目部署到tomcat的方式很多,我从一开始的打war包到tomcat/webapps目录,到使用tomcat-maven插件,到直接使用servers部署,一路来走过很多弯路. 下面就 ...
- java.lang.NoSuchFieldError: VERSION_2_3_0 报错解决方案
java.lang.NoSuchFieldError: VERSION_2_3_0 at org.apache.struts2.views.freemarker.FreemarkerManager.c ...
- CVS数据的导入和导出
2.CSV导入/导出测试 package junit.test; import java.io.File; import java.util.ArrayList; import java.util.L ...