python+selenium自动化测试定位下拉菜单并点击??

请问怎么写下图中的菜单定位并点击的脚本;
2024-12-29 23:12:07
推荐回答(2个)
回答1:

那就改用点击来解决.
先点击倒三角按钮, 然后点击option value="132"
另外select标签怎么有个editable=false ?

回答2:

请参考selenium.webdriver.support.select的API.

select_by_visible_text(text)[source]

Select all options that display text matching the argument. That is, when given “Bar” this would select an option like:

Args :

value - The value to match against

select_by_value(value)[source]

Select all options that have a value matching the argument. That is, when given “foo” this would select an option like:

Args :

index - The option at this index will be selected

select_by_index(index)

Select the option at the given index. This is done by examing the “index” attribute of an element, and not merely by counting.

Args :

options

Returns a list of all options belonging to this select tag

first_selected_option

The first selected option in this select tag (or the currently selected option in a normal select)


完整的API见http://seleniumhq.github.io/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.select.html#selenium.webdriver.support.select.Select.deselect_by_value