600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > selenium+python 遍历select下拉框获取value值

selenium+python 遍历select下拉框获取value值

时间:2023-06-10 17:30:46

相关推荐

selenium+python 遍历select下拉框获取value值

遍历下拉框,获取value值

因为多次需要,所以写成类方法,方便调用

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

参考文档:/landhu/p/5010723.html

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。