Link Checker

This is a XMLHttpRequest link checker I found on the internet:

Selenium.prototype.assertAllPageLinks = function () {
  var allLinks = selenium.getAllLinks();
  for(x=0; x<=allLinks.length;x++){
    var alink = selenium.getEval("window.document.links["+x+"];").toString();
    if(alink !="null" && alink.match(/mailto/g)!="mailto" && alink.match(/tel/g)!="tel" && alink.match(/javascript/g)!="javascript"){
      LOG.info("checking: "+alink);
      assertHTTPstatus(alink);
     }
   }	
  function assertHTTPstatus(url) {
    var req = new XMLHttpRequest();
    req.open('HEAD', url, false); 
    req.send();
    window.document.title = (url + " : " +req.status);
    var expectedValue = 'OK';
    var actualValue = 'OK';
    if(req.status != 200 && req.status!=302) {
      actualValue = (url + " ERROR " + req.status);
      window.document.title = (expectedValue + " : " + actualValue);
      Assert.matches(expectedValue, actualValue);
    }
   } 
};

Works in the IDE AND RC. Command is assertAllPageLinks. Just give it a URL

File: 

AttachmentSize
Plain text icon linkChecker.js.txt968 bytes

Type: 

User-Extension