【问题标题】:Casperjs click and ajaxCasperjs点击和ajax
【发布时间】:2014-02-26 18:22:45
【问题描述】:

我正在尝试在 easyjet.com 上使用 casperjs,因为它与我将来必须测试的非常相似,(结果页面中的 ajax 部分非常相似)。

在飞行结果页面中,当我点击一个链接时,我无法触发任何动作 ajax。

从调试中我看到链接被点击但没有触发 ajax 部分。

我不明白我错在哪里。

提前致谢

这是代码:

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"); 
    }); 
});

【问题讨论】:

  • 我猜是错字,但“#”和“Flight3987022”之间不应该有空格,“.”之间也不能有空格。和“priceSmaller”,但您确实需要在其他每个时期之前都有空格。

标签: ajax click casperjs


【解决方案1】:

去掉thenEvaluate()外层函数,直接调用casper.waitForSelector()

thenEvaluate() 用于在网页内运行 JavaScript。 casper 对象在该范围内不可用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多