title: How to find a parent link of a broken link with selenium?
body: <p>I found a list of broken links on a web site. </p>
  
  <pre><code>public static void main(String[] args) {
  
      String homePage = "http://www.example.com";
      String url = "";
      HttpURLConnection huc = null;
      int respCode = 200;
  
      driver = new ChromeDriver();
  
      driver.manage().window().maximize();
  
      driver.get(homePage);
  
      List&lt;WebElement&gt; links = driver.findElements(By.tagName("a"));
  
      Iterator&lt;WebElement&gt; it = links.iterator();
  
      while(it.hasNext()){
  
          url = it.next().getAttribute("href");
  
          System.out.println(url);
  
          if(url == null || url.isEmpty()){
              System.out.println("URL is either not configured for anchor tag or it is empty");
              continue;
          }
  
          if(!url.startsWith(homePage)){
              System.out.println("URL belongs to another domain, skipping it.");
              continue;
          }
              huc = (HttpURLConnection)(new URL(url).openConnection());
  
              huc.setRequestMethod("HEAD");
  
              huc.connect();
  
              respCode = huc.getResponseCode();
  
              if(respCode &gt;= 400){
                  System.out.println(url+" is a broken link");
              }
              else{
                  System.out.println(url+" is a valid link");
              }
  
      ...
  </code></pre>
  
  <p>But need to find the parent link. Where this broken URL is located (page URL). Is it possible to do it with selenium + (java + intellij idea)?
  Algorithm (no need the code), thanks.</p>