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

     def list_should_have_no_selections(self, locator):
"""Verifies select list identified by `locator` has no selections. 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.
"""
self._info("Verifying list '%s' has no selection." % locator)
select, options = self._get_select_list_options_selected(locator)
if options:
selected_labels = self._get_labels_for_options(options)
items_str = " | ".join(selected_labels)
raise AssertionError("List '%s' should have had no selection "
"(selection was [ %s ])" % (locator, items_str))

方法名:list_should_have_no_selections(self, locator)

公共方法 验证select list 没有项被选中

接收参数:locator

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

11行:使用_get_labels_for_options(self, options)返回选中options的labels数组

使用:

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

输出结果:

INFO : Verifying list 'id=creOutTime' has no selection.
上一篇:Selenium2Library系列 keywords 之 _SelectElementKeywords 之 unselect_from_list_by_label(self, locator, *labels)


下一篇:freecodecamp数字转化成罗马数字