def select_option(select_el, by, val):
"""Select an option from a select dropdown
Arguments:
select_el -- the Selenium WebDriver Element select dropdown
by -- the type of the value used (index | text | value)
val -- the value of the option to select
"""
select = Select(select_el)
if by == 'index':
return select.select_by_index(val)
elif by == 'text':
select.select_by_visible_text(val)
elif by == 'value':
select.select_by_value(val)
else:
raise Exception('Invalid SELECT BY type')
return True
评论列表
文章目录