Reputation: 1551
Have a link on the page:
<a id="quote" href="quote.html" target="_blank">Quote</a>
Click it in CasperJS, but I can't capture the page in new window.
casper.start('http://domain.com');
casper.thenClick('#quote');
casper.then(function() {
this.capture('file1.png');
});
casper.run();
Upvotes: 2
Views: 5965
Reputation: 5994
see also the documentation in casperjs about:
casper.waitForPopup();
casper.withPopup();
the new window(when clicking on link with target="_blank" attribute) can be considered as Popup.
document at: http://docs.casperjs.org/en/latest/modules/casper.html#waitforpopup
Upvotes: 4
Reputation: 971
casper.start('http://domain.com');
casper.thenClick('#quote');
casper.waitForResource('file1.png' , function() {
this.capture('file1.png');
});
casper.run();
You should try to wait for all the resources to be loaded, then proceed with other job. This will always work.
Upvotes: 0
Reputation: 1000
CasperJS doesn't work with new windows. You have to manually remove the "target=_blank" before cliking on the link :
this.evaluate(function () {
[].forEach.call(__utils__.findAll('a'), function(link) {
link.removeAttribute('target');
});
});
Upvotes: 1