2

ページにリンクがあります:

<a id="quote" href="quote.html" target="_blank">Quote</a>

CasperJS でクリックしても、新しいウィンドウでページをキャプチャできません。

casper.start('http://domain.com');
casper.thenClick('#quote');
casper.then(function() {
    this.capture('file1.png');
});

casper.run();
4

3 に答える 3

4

以下に関する casperjs のドキュメントも参照してください。

casper.waitForPopup();
casper.withPopup();

新しいウィンドウ (target="_blank" 属性のリンクをクリックしたとき) は、ポップアップと見なすことができます。

ドキュメント: http://docs.casperjs.org/en/latest/modules/casper.html#waitforpopup

于 2014-02-13T07:50:46.200 に答える
1

CasperJS は新しいウィンドウでは動作しません。リンクをクリックする前に、「target=_blank」を手動で削除する必要があります。

this.evaluate(function () {
    [].forEach.call(__utils__.findAll('a'), function(link) {
        link.removeAttribute('target');
    });
});
于 2013-11-07T10:12:10.483 に答える
0
casper.start('http://domain.com');
casper.thenClick('#quote');
casper.waitForResource('file1.png' , function() {
this.capture('file1.png');
});

casper.run();

すべてのリソースがロードされるのを待ってから、他のジョブに進む必要があります。これは常に機能します。

于 2014-02-05T07:51:42.807 に答える