[英]How to get pagesource of particular part of a webpage in Selenium webdriver
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.
正如我们现在所说的那样,driver.getPageSource()将返回整个页面源。
My concern is - Is there any way to get HTML content between two web elements? 我担心的是 - 有没有办法在两个网页元素之间获取HTML内容?
I managed to get some part of html by using the below method 我设法通过使用以下方法获取html的一部分
driver.findElement(By.xpath(xpathOfParentElement)).getAttribute("outerHTML");
Later, I parsed the htmlString in the below method 后来,我在下面的方法中解析了htmlString
org.jsoup.Jsoup.parse(htmlString).text();
Maven Dependency : Maven依赖:
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.9.2</version>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.