I was wondering if there is a way to get all the html code between two element tags along with the element tag and then save it in a string.
Suppose I use the following to create a list of web elements, and then populate the list with all web elements.
List<WebElement> element = driver.findElements(By.xpath("//*"));
//Some for loop after this to access each value
If I use the following to get the third web element, it prints only the tag name, as it should:
System.out.println(element.get(3).getTagName());
therefore, it prints the paragraph element "p" or "input", for example, if it is the third web element saved
But I was wondering, is it possible to get the entire line of html code for a web element and print it, and not just the tag name “p”, for example?
eg.
<p> some text </p>
Is there any way to do this?