【发布时间】:2015-04-27 16:57:25
【问题描述】:
在 Python、Java 和其他几个 selenium 绑定中,对select->option HTML 结构有一个非常方便的抽象,即Select class。
例如,假设有以下select 标签:
<select id="fruits" class="select" name="fruits">
<option value="1">Banana</option>
<option value="2">Mango</option>
</select>
下面是我们如何在 Python 中操作它:
from selenium.webdriver.support.ui import Select
select = Select(driver.find_element_by_id('fruits'))
# get all options
print select.options
# get all selected options
print select.all_selected_options
# select an option by value
select.select_by_value('1')
# select by visible text
select.select_by_visible_text('Mango')
换句话说,它是一个非常透明且易于使用的抽象。
是否可以以类似的方式在量角器中操作select 标签?
这不是 How to select option in drop down protractorjs e2e tests 或 How to click on option in select box in Protractor test? 的副本。
【问题讨论】:
-
为什么需要赏金?
-
@tox123 这是我表达感谢的方式。
-
哦,事后看你的代表,你可以拿-50分。
标签: python testing selenium selenium-webdriver protractor