weixin_33711647 2014-02-26 18:22 采纳率: 0%
浏览 35

Casperjs Click和Ajax

I'm trying to use casperjs on easyjet.com because it is very similar to what I have to test in the future, (very similar ajax part in result page).

In the flight results page when I click on a link I can not trigger any action ajax.

From debugging I see that the link is then clicked but does not trigger ajax part.

I cannot understand where I'm wrong.

Thanks in advance

this is the code:

casper.thenEvaluate (function () {
    casper.waitForSelector ("# Flight3987022. priceSmaller.targetPrice.formatedPrice.cellPrice", 
        function success () {
            casper.assertExists ("# Flight3987022. priceSmaller.targetPrice.formatedPrice.cellPrice"); 
            this.click ("# Flight3987022. priceSmaller.targetPrice.formatedPrice.cellPrice"); 
        }, 
        function fail () {
           casper.assertExists ("# Flight3987022. priceSmaller.targetPrice.formatedPrice.cellPrice"); 
    }); 
});

  • 写回答

1条回答 默认 最新

  • weixin_33709609 2014-03-03 23:44
    关注

    Get rid of the thenEvaluate() outer function, and call casper.waitForSelector() directly.

    thenEvaluate() is used for running JavaScript inside the web page. The casper object isn't available in that scope.

    评论

报告相同问题?