Reputation: 319
I'm trying to take 2 screenshot from a website - One before an injection into the site, and one after.
Problem is - when I try to take the first screenshot after all the assets were loaded (and before I inject my script) - it won't create the screenshot from inside the onInitialized function.. any clue why?
page.onInitialized = function () {
page.render('e1.png');
page.evaluate(function () {
<here i'm injectingo the page>
});
};
Also - how can I compare between the 2 screenshots with resemble js? I installed the package with npm, and i'm running the test with phantomjs, so what is the way to save the screenshot created via phantomjs into variables and then compre with resemble.js? I'll be glad to see a code which is working for my need. Thank you very much!!
Upvotes: 0
Views: 709
Reputation: 61902
The page.onInitialized
event is
invoked after the web page is created but before a URL is loaded.
You need to use page.onLoadFinished
or the callback in page.open
to wait until a page with all its resources is loaded. Note that you will need to wait with setTimeout
after that if the page is dynamically generated through JavaScript.
Upvotes: 0