Access a button with its name in Selenium Python

Question:

enter image description here

These are the html for a button which changes x-path dynamically but "Show Actions" remains the same. I am confused whether "Show Actions" is name, title or id of the button.

Is there anyway to click this button with "Show Actions" or any other ways?

Asked By: Sriram

||

Answers:

Show Actions seems to be the text content of the element.
You can try clicking it with the following way:

driver.find_element(By.XPATH, "//span[contains(text(),'Show Actions')]").click()

Or

driver.find_element(By.XPATH, "//span[contains(.,'Show Actions')]").click()

You will possibly need to add an expected condition to wait for this element clickability, as following:

wait.until(EC.element_to_be_clickable((By.XPATH, "//span[contains(.,'Show Actions')]"))).click()
Answered By: Prophet
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.