I am trying to test HTTP RESPONSE of all href links on the page, using WebDriver to fetch all the links from the page and then using http.connect to get the response status.
Code snippet to get links of anchor tag:
List<WebElement> list = driver.findElements(By.cssSelector("a"));
for (WebElement link : list) {
System.out.println(link.getText());
}
But my page has many more href links which are not having anchor tag <a> and might reside outside body of the page in header section or so. Some examples are as shown below. Above webdriver code wont solve in fetching all types of links. Also need to extract src links in some cases...
<script src="https://www.test.com/js/50/f59ae5bd.js"></script>
<link rel="stylesheet" href="www.test.com/css/27/5a92c391c7be2e9.css" rel="stylesheet" type="text/css" />
<link sizes="72x72" href="https://www.test.com/css/27/5a92c391c7b/kj32.png" />
<li><a href="https://www.test.com/webapps/mpp/resortcheck">resortcheck</a>
I would appreciate if someone can guide how to go about or has resolved similar issues in getting all href links from page.