Selenium2Library系列 keywords 之 _SelectElem

系统 1674 0
      
         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.
    

 

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


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论