首页 > 解决方案 > Casper JS 在点击时卡住了

问题描述

我是新手casperJS,我正在尝试填写表格。当我单击按钮时,this.click('input[type="button"][value="Add"][class="ui-btn-hidden"]'); 我会在控制台中看到一些输出,即单击按钮时的控制台输出,例如在此处输入图像描述

我在终端中看到相同的输出,我的脚本卡住了,我看到了错误Wait timeout of 10000ms expired, exiting.

执行点击后如何不等待输出直接跳到下一步?

编辑 我的代码是

casper.then(function () {


    this.evaluate(function () {
        if (!$('#add-button').is(':visible')){
            this.echo("add button visible");
            $('#yourHeader').click();
            this.echo("add button clicked");
        }
        $('#add-header').click();
        this.echo("add header clicked");
    });
    this.waitUntilVisible('input[id="newAmount"]');

    this.capture(CapturePath('add_form.png'));
    this.evaluate(function () {

        $("#newType option:contains('Direct')").prop('selected', true).change();
        this.echo(" type selected");
    });
    this.capture(CapturePath('filledForm.png'));
    this.sendKeys('input[id="newAmount"]', Balance);
    this.echo("new amount set as "+loanBalance);
    this.capture(CapturePath('filledFormamount.png'));
    this.sendKeys('input[id="newInterest"]', interestRate);
    this.echo("new interest rate set as "+interestRate);
    this.capture(CapturePath('filledFormInterest.png'));
    this.echo('clicking ui-btn-hidden');
    this.click('input[type="button"][value="Add"][class="ui-btn-hidden"]');


    this.capture(CapturePath('CompletedForm.png'));

    this.capture(CapturePath('selectFound.png'));
    this.echo("here I am");
});

casper.run(function () {
    this.echo('Done').exit();
});

我从来没有看到用这段代码完成

标签: javascriptformsphantomjscasperjs

解决方案


推荐阅读