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");