Reputation: 427
I have a button which has two states - enabled and disabled
Enabled State:
<button type="button" class="btt-download-csv site-toolbar-menu-button icon-download no-icon-margins ng-isolate-scope" title="Download CSV" rc-download-csv="" current-segment-path="all" ng-disabled="noCustomers || loadingCustomers" ng-show="!deleteModeEnabled"></button>
Disabled State:
<button type="button" class="btt-download-csv site-toolbar-menu-button icon-download no-icon-margins ng-isolate-scope" title="Download CSV" rc-download-csv="" current-segment-path="all" ng-disabled="noCustomers || loadingCustomers" ng-show="!deleteModeEnabled" disabled=""></button>
Notice a disabled=""
word by the end of the code. How do I specify that I want to click on a button that is NOT disabled?
I use the following css selector but it does not care about state of the button:
"button.btt-download-csv.site-toolbar-menu-button.icon-download.no-icon-margins.ng-isolate-scope"
Upvotes: 1
Views: 51
Reputation: 61
If you want to disable a button, just add the attribute disabled
.
Normal button: <button type="button"></button>
Access this button with css: button {}
Disabled button: <button type="button" disabled></button>
Access this button with css: button[disabled] {}
Upvotes: 0
Reputation: 50949
You can use css_selector
to locate an element without specific attribute
driver.find_element_by_css_selector('[title="Download CSV"]:not([disabled])')
Or with xpath
driver.find_element_by_xpath('//button[@title="Download CSV"][not(@disabled)])
Upvotes: 2