微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

selenium+python 获取select中的所有option

def is_option_value_present(self,element_id,tag_name,option_text):
        driver = self.driver
        select=driver.find_element_by_id(element_id)
        # 注意使用find_elements
        options_list=select.find_elements_by_tag_name(tag_name)
        for option in options_list:
            # print ("Value is: " + option.get_attribute("value"))
            # print ("Text is:" +option.text)
            if option_text in option.text:
                select_value=option.get_attribute("value")
                print ("option_textoption_textoption_textValue is: " + select_value)
                break
        return select_value

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐