I was wondering if there was a way to get the entire html code between two tags of an element, along with the element tag then store it in a string.
Lets say I use the following to create a list of web elements, then fill the list with all the 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 3rd web element, it prints only the tags name, as it should:
so it prints the paragraph element "p" or "input" for example if it is the 3rd web element stored
But I was wondering if its possible to get the entire html code line for the web element and print it rather then only the tag name "p" for example?
<p> some text </p>
Is there some way to accomplish this?
You can read
outerHTML attribute to get the entire element.
Or in your case:
Hope it helps!