首页 > 其他 > 详细

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

时间:2015-04-29 00:32:20      阅读:311      评论:0      收藏:0      [点我收藏+]
 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.

 

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

原文:http://www.cnblogs.com/loveok-56/p/4464238.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!