Reputation: 17
</p>
<p>
<label>Capacity:</label>
<select name="capacity">
<option value="Small">Small</option>
<option value="Medium">Medium</option>
<option value="Large">Large</option>
</select>
</p>
<p>
policy_mgmt = Select(mydriver.find_element_by_xpath("//select[@name='Capacity']"))
policy_mgmt.select_by_value("Medium")
I also tried below code
mydriver.find_element_by_xpath(".//select[@name='capacity']").click()
mydriver.find_element_by_xpath("//select[@name='capacity'] /option[@value='Medium']").click()
This clicks on the drop down and I can see all the options on the webpage, but it does not select "Medium" as I expect.
Any help will be highly appreciated
Upvotes: 0
Views: 169
Reputation: 1477
browser.find_element_by_xpath(".//select[@name='capacity']/option[text()='Medium']").click()
Upvotes: 0
Reputation: 50809
xpath
is case sensitive, it should be capacity
with lowercase 'c'
policy_mgmt = Select(mydriver.find_element_by_xpath("//select[@name='capacity']"))
Upvotes: 2