【问题标题】:How to get the URL when download button is pushed in CasperJS在CasperJS中按下下载按钮时如何获取URL
【发布时间】:2018-01-26 07:45:01
【问题描述】:

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

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

【问题讨论】:

  • 这个按钮的当前行为是什么?你没有说清楚,我猜它下载一个文件?能否提供页面链接?

标签: javascript casperjs


【解决方案1】:

您可以使用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();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-15
    • 1970-01-01
    • 2021-06-02
    • 2019-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多