Reputation: 81
The html source is below
<select id="ca_vdcs" class="pulldown small" name="vdc" style="display: none;">
<option>-- Select a vDC --</option>
<option>Platform-VDC-org</option>
</select>
I want to select the 'Platform-VDC-org', but the below code is not working.
select = browser.find_element_by_id('ca_vdcs')
select.find_element_by_xpath("//option[@value='Platform-VDC-org']").click()
Upvotes: 6
Views: 11723
Reputation: 5453
You should try using the Select()
class. It makes dealing with select elements
much easier.
select = Select(browser.find_element_by_id("ca_vdcs"))
select.select_by_visible_text("Platform-VDC-org")
You can see the WebDriver API bindings in Python here:
http://selenium-python.readthedocs.org/en/latest/api.html
The Select()
class is at section 7.12. UI Support
Upvotes: 9