I am looking for a way to pull the html or text content of a so I could work with it for a method which validates links amongst text of messages displays on a webpage. I am using selenium and java.
<div> "This link" <a href="http://www.google.com">http://www.google.com</a> "exists." </div>
I have been researching ways to pull the html of the link from a single message and most of what I have encountered allows you to pull the text of the 'href' attribute or the link text. It may not be possible. Preferably, I would like to pull all the content from the div.
I have tried something similar to this below but it returns 'http://www.google.com'.
WebElement e = driver.findElements(By.tagName("a")); String content = e.getAttribute("innerHTML");
I have also tried using xpaths using contains() and text(). Both return the text of link but not anything else.
Any ideas what I could try?