1 def select_all_from_list(self, locator): 2 """Selects all values from multi-select list identified by `id`. 3 4 Key attributes for lists are `id` and `name`. See `introduction` for 5 details about locating elements. 6 """ 7 self._info("Selecting all options from list '%s'." % locator) 8 9 select = self._get_select_list(locator) 10 if not select.is_multiple: 11 raise RuntimeError("Keyword 'Select all from list' works only for multiselect lists.") 12 13 for i in range(len(select.options)): 14 select.select_by_index(i)
方法名:select_all_from_list(self, locator)
公共方法 选中所有选项,适用于multi-select list
接收参数:locator
9行:使用_get_select_list(self, locator)方法,返回Select对象
13、14行:遍历所有options,并选中
使用:
输出结果:
INFO : Selecting all options from list 'id=creOutTime'.