Reputation: 449
I want to click this button using css_selector.
<div class="ui-buttonset">
<button class="ui-button ui-dfault ui-text-only" type=" button"
role="button" aria-disabled="false">
<span class-"ui-button-text">Save</span>
</button>
</div>
There are 2 buttons save and cancel. They both have the same code. How do I click the save button using css_selector?
I have tried driver.find_element_by_css_selector("button.ui-button").click()
But it doesn't work.
Upvotes: 1
Views: 3943
Reputation: 28648
You can use one of the following selectors:
driver.find_element_by_css_selector("button.ui-button:first-child").click()
driver.find_element_by_css_selector("button.ui-button:last-child").click()
Upvotes: 1