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

 1     def list_should_have_no_selections(self, locator):
 2         """Verifies select list identified by `locator` has no selections.
 3 
 4         Select list keywords work on both lists and combo boxes. Key attributes for
 5         select lists are `id` and `name`. See `introduction` for details about
 6         locating elements.
 7         """
 8         self._info("Verifying list '%s' has no selection." % locator)
 9         select, options = self._get_select_list_options_selected(locator)
10         if options:
11             selected_labels = self._get_labels_for_options(options)
12             items_str = " | ".join(selected_labels)
13             raise AssertionError("List '%s' should have had no selection "
14                                  "(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数组

使用:

输出结果:

INFO : Verifying list 'id=creOutTime' has no selection.
原文地址:https://www.cnblogs.com/loveok-56/p/4464215.html