title: Fetching all href links from the page source using Selenium WebDriver with Java
body: <p>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.</p>
  
  <p>Code snippet to get links of anchor tag:</p>
  
  <pre><code>List&lt;WebElement&gt; list = driver.findElements(By.cssSelector("a"));
  for (WebElement link : list) {
      System.out.println(link.getText());
  }
  </code></pre>
  
  <p>But my page has many more href links which are not having anchor tag <code>&lt;a&gt;</code> 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...</p>
  
  <pre><code>&lt;script src="https://www.test.com/js/50/f59ae5bd.js"&gt;&lt;/script&gt; 
  &lt;link rel="stylesheet" href="www.test.com/css/27/5a92c391c7be2e9.css" rel="stylesheet" type="text/css" /&gt;
  &lt;link sizes="72x72" href="https://www.test.com/css/27/5a92c391c7b/kj32.png" /&gt;
  &lt;li&gt;&lt;a href="https://www.test.com/webapps/mpp/resortcheck"&gt;resortcheck&lt;/a&gt;
  </code></pre>
  
  <p>I would appreciate if someone can guide how to go about or has resolved similar issues in getting all href links from page.</p>