如何在CasperJS中按下下载按钮时获取URL

时间:2018-01-26 07:45:01

标签: javascript casperjs

我想点击CasperJS中的“下载”按钮后获取URL。

<a href="javascript:void(0);" onclick="return Support.DownloadContent('', 'content','contents');">Download</a>

1 个答案:

答案 0 :(得分:0)

您可以使用click(),然后使用getCurrentUrl()

var casper = require('casper').create();

casper.start('https://example.com/');

casper.then(function () {
  this.click('a');
});

casper.then(function () {
  this.echo(this.getCurrentUrl());
});

casper.run();
相关问题