Reputation: 35
I running into a problem where I need to find a non disabled button on a page but the buttons share the same class name whether they are disabled or not(also the same innerText). They do have an additional class added to them if they are disabled.
I need a way to select a element and check if it doesn't have the class for disabled buttons Thanks
loginBtn = browser.find_element_by_class_name('c-shus-layout-bar__menu-button')
loginBtn.click()
Upvotes: 0
Views: 124
Reputation: 33361
In case you need to locate button element containing some class name, say c-shus-layout-bar__menu-button
and not containing some other class name, say disabled
you can use the following xpath
:
//button[contains(@class,'c-shus-layout-bar__menu-button') and (not(contains(@class,'disabled')))]
Upvotes: 2