how do i check if a button is clickable in selenium when the class changes?

XPATH could be quite flexible and allows to refer a lot of element node’s data and also in advance it alows some logical conditions, etc. So I believe it’s very powerful and flexible enough to produce some targeted and not fragile results.

Regarding your case:

clickable_button_xpath = "//a[@type='button'][contains(., 'Ship to Home') and contains(@class, '-unselected')]"
selected_button_xpath = "//a[@type='button'][contains(., 'Ship to Home') and contains(@class, '-selected')]"
unclickable_button_xpath = "//a[@type='button'][contains(., 'Ship to Home') and contains(@class, '-unclickable')]"

some_element = driver.find_element(By.XPATH, some_xpath)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top