Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97785

How to take text from an HTML element which uses a custom attribute?

$
0
0

I am working on Selenium framework 2.0 Web driver and I would like to get value from a span which has a attribute like data-automation-id. The HTML code is as below

<span data-automation-id="SEL_ERR">
  Error Description
</span>

Now I want to read the text with in span that has a attribute data-automation-id set to SEL_ERR.

Can some one help me in fixing the code as I have already tried the one below but in vain.

driver.findElement(By.tagName("span")).getAttribute("data-automation-id");

Viewing all articles
Browse latest Browse all 97785

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>