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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM