I am trying to get pagesource of a specific part of the page. As we now that driver.getPageSource() will returns the entire source of the page.
My concern is - Is there any way to get HTML content between two web elements?
I managed to get some part of html by using the below method
driver.findElement(By.xpath(xpathOfParentElement)).getAttribute("outerHTML");
Later, I parsed the htmlString in the below method
org.jsoup.Jsoup.parse(htmlString).text();
Maven Dependency :
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.9.2</version>
</dependency>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.