Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ with your query.

Test broken links on a webpage

YashrajYashraj Members
edited January 10 in Sahi Pro
Hi could you please help me with finding all the links on a web page and testing if they're broken or not.
I found this code on the sahi community forum and edited it a little bit but seems not be working.
I'm completely new to sahi pro and still trying to figure out the tool. I've created similar script previously but using different automation tool.

/***************************Broken Link********************************/

function getLinks(){
var links = window.document.links;
var store = [];
for (var i=0; i<links.length; i++){
store[store.length] = {text:_sahi._getText(links), url:links.href};
return store;

function testBrokenLinks(){
_set($links, getLinks());
for (var $j=0; $j<$links.length; $j++){
_wait(10000, _sahi.loaded);
if (_condition(_containsText(document.body, "Either the remote server is down or not reachable"))){
_log($links[$j].text + " (" + $links[$j].url + ") is broken", "failure");
_log($links[$j].text + " (" + $links[$j].url + ") is fine", "success");

I'll be calling these two functions in the script.
Any help would be really appreciated.
Sign In or Register to comment.