Selenium2Library系列 keywords 之 _SelectElementKeywords 之 get_selected_list_values(self, locator)

     def get_selected_list_values(self, locator):
"""Returns the values of selected elements (as a list) from the select list identified by `locator`. Fails if there is no selection. 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.
"""
select, options = self._get_select_list_options_selected(locator)
if len(options) == 0:
raise ValueError("Select list with locator '%s' does not have any selected values")
return self._get_values_for_options(options)

方法名:get_selected_list_values(self, locator)

相似方法:

公共方法 返回所有选中项的values数组

接收参数:locator

10行:使用_get_select_list_options_selected(self, locator)方法返回Select 元素对象和选中options数组

13行:返回所有选中项的value数组

使用:Selenium2Library系列 keywords 之 _SelectElementKeywords 之 get_selected_list_values(self, locator)

输出结果:

INFO : @{values} = [ 0 | 1 | 2 ]
上一篇:Selenium2Library系列 keywords 之 _SelectElementKeywords 之 select_from_list(self, locator, *items)


下一篇:OpenJudge计算概论-鸡兔同笼【新版题目,简单计算级别】