get href value (WebDriver)

Viewed 94862

How do I get a value from href?

like this eg:

<div id="cont"><div class="bclass1" id="idOne">Test</div>

    <div id="testId"><a href="**NEED THIS VALUE AS STRING**">
    <img src="img1.png" class="clasOne" />
    </a>

</div>
</div>
</div>

I need that value as string.

I've tried with this:

String e = driverCE.findElement(By.xpath("//div[@id='testId']")).getAttribute("href");
            JOptionPane.showMessageDialog(null, e);

But just returns NULL value...

2 Answers
Related