0

The html text below exits on a page. I am trying to have selenium click the button that this tag is referring to. I can not search this href because the id for given app is unknown and link will always have a different id. I have to click on this button by locating it by text inside button which is "New Database/Server"

<a class="btn btn-primary" data-turbo-frame="modal" href="/repo/servers/new?repo_application_id=280"><svg class="bi flex-shrink-0 me-2" height="24" role="img" width="24"><use href="#icon_database-plus"></use></svg><span class="pe-3">New Database/Server</span></a> 

How do I have the driver go to this href link?

1 Answer 1

1

Use following xpath to click on the button.

driver.find_element(By.XPATH, "//a[.//span[text()='New Database/Server']]").click()

or use link_text

driver.find_element(By.LINK_TEXT, "New Database/Server").click()
Sign up to request clarification or add additional context in comments.

1 Comment

Both scripts worked!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.