Open and close all links inside a page for testing

For web site testing, we need to open each links on a page and briefly exam the page display.

1. set each link displays for 5 seconds or longer before closing to ensure there is enough time for a link to be fully opened and examined.
2. set open interval of each link to 3 seconds more than the link being closed. This allows js to ensure the previous link is closed before open the next link.

var key_start = 0;
var win;
$.each($('#sitemapTable a'),function(key,value){
	if(key >= key_start)
	setTimeout(function(){
		  win = window.open(value.href);
		  setTimeout(function(){
			win.close();
		  }, 5000);
	},(key-key_start)*(8000+Math.floor(Math.random() * 100)));
});

Note:
1. tested in Chrome 70.0.3538.102.
2. this script is used in js console.

154 total views, 1 views today

Author: Albert

Leave a Reply