Using this code below I get the href
from a link element.
Sting url
List<WebElement> wElements = DriverFactory.getWebDriver().findElements(By.className("link-class"))
if(wElements.size() > 0) {
url = wElements[0].getAttribute("href")
}
The problem is that it finds the element but not the href
attribute!!!
If I use "Firefox Inspector" the element appears as <span>
with the right class name but without href
attribute.
<div><span class="link-class">The Title</span></div>
If I use the "View Page Source" the same element appears as an <a>
tag, it has href
attribute, but different class name!!!
<a href="/href/attribute/here" class="other-link-class"<span>The Title</span></a>
So, is there any way to get the href
of an <a>
element but as it shown in "View Page Source"? Using Java of course.