select.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:nerodia 作者: watir 项目源码 文件源码
def _find_options(self, how, term):
        types = [six.text_type, six.binary_type, int, re._pattern_type]
        found = []

        def func(sel):
            if type(term) in types:
                collection = sel.options(value=term) if how == 'value' else []
                if not list(collection):
                    collection = sel.options(text=term)
                if not list(collection):
                    collection = sel.options(label=term)
                if collection:
                    found.append(collection)
                    return False
                else:
                    return not found and nerodia.relaxed_locate
            else:
                raise TypeError('expected {!r}, got {}:{}'.format(types, term, term.__class__))

        try:
            Wait.until_not(func, object=self)
            if found:
                return found[0]
            raise NoValueFoundException('{} not found in select list'.format(term))
        except TimeoutError:
            raise NoValueFoundException('{} not found in select list'.format(term))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号