Search code examples
javascripthtmlweb-testing

How to traverse website, get all console


Say I have a website with the following pages:

page1.html, page2.html, page3.html

for each one of these pages, load the page, and get the console logs.


Solution

  • Use iframe and load your next html files changing .src with onload event. The console.logs from each html file will be shown in your console.

    var iframe = document.getElementById('iframe');
    var iter = 0;
    var myLinks = ['page1.html','page2.html','page3.html']; //replace with your correct existing urls
    iframe.src = myLinks[0];
    
    iframe.onload = function(){
    	iter++;
    	if(iter===myLinks.length) return;
    	iframe.src = myLinks[iter];
    };
    <iframe id="iframe" src=""></iframe>