Casper JS在点击

时间:2018-04-30 22:43:13

标签: javascript forms phantomjs casperjs

我是casperJS的新手,我正在尝试填写表格。当我点击this.click('input[type="button"][value="Add"][class="ui-btn-hidden"]');按钮时 我看到我的控制台中有一些输出是点击按钮的控制台输出,例如enter image description here

我在终端看到相同的输出,我的脚本卡住了,我看到错误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();
});

我从未见过使用此代码完成

0 个答案:

没有答案