0

The printing of 'opened page one' or 'opened 2nd page' happens in random order. Can anyone please tell me why that is? And is there a way to get them to always open in order?

var page = require('webpage').create();
var page1 = require('webpage').create();
var page2 = require('webpage').create();


page.open('http://www.yourhtmlsource.com/myfirstsite/', function () {
  setTimeout(function(){

    console.log('opened page one');


   // phantom.exit();
  }, 2000); 
 });
page1.open('http://csb.stanford.edu/class/public/pages/sykes_webdesign  /05_simple.html', function () {
  setTimeout(function(){

   console.log('opened 2nd page');

   }, 2000);
});
page2.open('http://www.sheldonbrown.com/web_sample1.html', function () {
  setTimeout(function(){

    console.log('opened 3rd');
    phantom.exit();

    }, 2000);
});
user3270763
  • 125
  • 1
  • 3
  • 13
  • Possible duplicate of [Using Multiple page.open in Single Script](http://stackoverflow.com/questions/16996732/using-multiple-page-open-in-single-script) (`args` is the URL array) – Artjom B. Nov 12 '15 at 21:19
  • 1
    `page.open()` is asynchronous, so they will open all at the same time and compete for the bandwidth that you have available. – Artjom B. Nov 12 '15 at 21:20

0 Answers0