0

I have below html.

<button>save</button>
<button>Cancel</button>
<button>View</button>

I want to click on button if name is save.

button = driver.find_element_by_xpath(
            "(//button[contains(@name, 'save')])")

I am able to do it if button has a name. But if button has no name like my example how can I click on it?

2 Answers 2

1

Take button txt by XPATH.

button = driver.find_element(By.XPATH, '//button[text()="save"]')

button.click()

For more details click

Sign up to request clarification or add additional context in comments.

Comments

0

Like this if has no name:

button = driver.find_element_by_xpath(
            "(//button[contains(@name, '')])")

1 Comment

There has 3 buttons I want to click on save button. and every buttons has no name attribute.

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.