Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript casperjs按钮点击不';t导航到下一页_Javascript_Html_Phantomjs_Casperjs - Fatal编程技术网

Javascript casperjs按钮点击不';t导航到下一页

Javascript casperjs按钮点击不';t导航到下一页,javascript,html,phantomjs,casperjs,Javascript,Html,Phantomjs,Casperjs,我有一个包含HTML表单和javascript设置的页面,比如如果你点击一个带有someid的按钮,表单就会被提交。我通过在浏览器控制台中启动以下命令验证了这一点: document.getElementById(“arcotsubmit”)。单击() 一旦被激发,url就会改变,表单就会被提交 现在,我尝试用casper.js复制这一点: var casper = require('casper').create({}); casper.start('https://cib.iciciba

我有一个包含HTML表单和javascript设置的页面,比如如果你点击一个带有someid的按钮,表单就会被提交。我通过在浏览器控制台中启动以下命令验证了这一点:

document.getElementById(“arcotsubmit”)。单击()

一旦被激发,url就会改变,表单就会被提交

现在,我尝试用casper.js复制这一点:

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


casper.start('https://cib.icicibank.com/corp/BANKAWAY?Action.CorpUser.Init1.001=Y&AppSignonBankId=ICI&AppType=corporate', function() {
    this.echo(this.getTitle());
});

casper.then(function(){

    this.click("#arcotsubmit");

});

casper.then(function(){

    console.log(this.getCurrentUrl())
});

casper.run();
它保持在相同的URL上,并下载相同的页面。我想下载casper单击按钮后显示的html。URL是实时的,可以直接测试

我的观点是,我是否可以在浏览器控制台中使用此命令

document.getElementById("arcotsubmit").click()
让它重定向,为什么我不能用
点击casperjs中的“#arcotsubmit”?

可能的快速修复。若Casper的单击不起作用,但您的代码在浏览器的控制台中工作,请尝试使用Casper的函数

casper.then(function() {
  this.evaluate(function() {
    document.getElementById("arcotsubmit").click();
  });
});

它是提交,而不是单击进行重定向。input[type=image]的默认事件是submit,请尝试以下操作:

casper.test.begin('Test page.', 2, function suite(test) {
    casper.start(
        'https://cib.icicibank.com/corp/BANKAWAY?Action.CorpUser.Init1.001=Y&AppSignonBankId=ICI&AppType=corporate',
        function() {
            this.echo(this.getTitle());
            test.assertUrlMatch(/BANKAWAY?/, 'Current location is ' + this.getCurrentUrl());
        }
    );

    casper.then(function(){
        this.fill('#rt', {}, true);
        this.wait(2000, function() {
            test.assertUrlMatch(/BANKAWAY;/, 'New location is ' + this.getCurrentUrl());
        });
    });

    casper.run(function() {
        test.done();
    });
});
它将被通过。

你有没有找到解决办法,因为我也有同样的问题?而且,我使用的是直幻影。