0

So, imagine a page that has the following HTML:

<button data-my-custom='{"fileName":"SomethingRandom.zip"}'>
                 Download build 1023
</button>

There will be several of these on the page, each will have a different filename value for the data-my-custom HTML 5 attribute.

How can I get the elements that contain the HTML5 attribute "data-my-custom" in Selenium?

I cannot figure out if I should use XPATH and if so, what the expression would be?

Thank you.

4
  • Possible duplicate of Selenium webdriver (c#) - Finding button based on attribute Commented May 26, 2017 at 0:44
  • The xpath expression would be //button[@data-my-custom]. Commented May 26, 2017 at 1:04
  • 2
    For CSS-path, the selector will be: button[data-my-custom], or button[data-my-custom=<{yourFileNameObject}>] if you want to find a specific one. Commented May 26, 2017 at 3:30
  • Thanks. This worked.... (without the @symbol) Commented May 26, 2017 at 4:21

1 Answer 1

0

For CSS-path, the selector will be: button[data-my-custom], or button[data-my-custom=<{yourFileNameObject}>] if you want to find a specific one.

Full credit to iamdanchiv.

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

Comments

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.