I have a script (below) that crosses a website with a three-step process. It works great when set to a maximum of 1 page at a time. however, when I increase it to 2 at a time, everything starts to get awkward. onFinished fires sooner than I would expect, and the page is not yet fully loaded. because of this, the rest of my script breaks. any idea why this might happen? I must add that I am using the latest version (1.5).
MAX_PAGES = 1 newPage = (id) -> context = {} context.id = id context.step = 0 context.page = require('webpage').create() context.page.onLoadStarted = -> context.step++ context.page.onLoadFinished = (status) -> console.log status if status is 'success' context.page.render("#{context.id}_#{context.step}.png") else context.page.release() context.page.open('http://www.microsoft.com') console.log 'started loading' newPage id for id in [1..MAX_PAGES]
source share