selenium下拉框选择

下拉框结构如下,我需要选择的是new:

selenium下拉框选择

html为:

<select id="condition_type" name="condition_type" class="notification-required notification-required-unknown">
<option value="">
- Select -</option>
<option value="new, new">
New</option>
<option value="used, like_new">
Used - Like New</option>
<option value="used, very_good">
Used - Very Good</option>
<option value="used, good">
Used - Good</option>
<option value="used, acceptable">
Used - Acceptable</option>
<option value="refurbished, refurbished">
Refurbished</option>
</select>

代码:

from selenium.webdriver.support.select import Select
# 定位到下拉框,选择new
sel = browser.find_element_by_xpath("//select[@id='condition_type']")
Select(sel).select_by_value('new, new')
上一篇:Win10技巧:如何确定电脑是否适用Hyper-V虚拟机?


下一篇:Windows API中几个函数的总结