0

How can i get value of custom attribute ('173136' from data-id and 'NORMAL' from data-status for example) inside of div using Selenium Webdriver in ruby?

<div class="trow " data-id="173136" data-status="NORMAL" data-running="false">

I found that watir-webdriver can afford that https://jkotests.wordpress.com/2012/11/23/get-attribute-values-of-the-html-element/, but as I mentioned we are using selemium-webdriver. Any suggestions?

1 Answer 1

3

It's very easy, just:

browser.div(somes identificator like :xpath or :text).data_id
browser.div(somes identificator like :xpath or :text).data_status

But, yes, it's for Watir..for selenium it's somes like:

driver.find_element(:xpath, "some xpath").attribute("data-id")
driver.find_element(:xpath, "some xpath").attribute("data-status")
Sign up to request clarification or add additional context in comments.

1 Comment

I think there is a typo. The string passed to the attribute method should exactly match the attribute name. For example, it should be data-id instead of data_id.

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.