Mr_links
Mr_links

Reputation: 35

selenium webdriver : find a classname in a located element

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

Answers (1)

Prophet
Prophet

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

Related Questions