You*_*ung 6 webdriver python-2.7 selenium-webdriver
html源代码如下
<select id="ca_vdcs" class="pulldown small" name="vdc" style="display: none;">
<option>-- Select a vDC --</option>
<option>Platform-VDC-org</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我想选择'Platform-VDC-org',但下面的代码不起作用.
select = browser.find_element_by_id('ca_vdcs')
select.find_element_by_xpath("//option[@value='Platform-VDC-org']").click()
Run Code Online (Sandbox Code Playgroud)
你应该尝试使用这个Select()类.它使处理select elements更容易.
select = Select(browser.find_element_by_id("ca_vdcs"))
select.select_by_visible_text("Platform-VDC-org")
Run Code Online (Sandbox Code Playgroud)
您可以在此处查看Python中的WebDriver API绑定:
http://selenium-python.readthedocs.org/en/latest/api.html
该Select()课程在第7.12节.UI支持
| 归档时间: |
|
| 查看次数: |
11632 次 |
| 最近记录: |