title: How to check broken links in a webpage using Casperjs?
body: <p>I want to check all broken links present in a webpage using casperjs. I write following code but it not working:</p>
  
  <pre><code>casper.then(function() {
       var urls=casper.getElementsAttribute('a[href]', 'href');
      casper.eachThen(urls, function(response) {
          var  link=response.data;
          this.thenOpen(demourl, function(response) { 
               if (response == undefined || response.status &gt;= 400) {
                  this.echo("failed");
              }
          })
  
          this.on('http.status.404', function(resource) {
              this.echo('wait, this url is 404: ' + resource.url);
          })
      })
  })
  </code></pre>
  
  <p>My Webpage consists of more than 400 links. My code doesn't complete its execution and remains idle after some links. It is not giving me any response. I am not getting why this happening?</p>