Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Access a button with its name in Selenium Python

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading