casperjs-css选择器存在,但当单击它时会引发“”;CasperError:无法在不存在的选择器“”上调度mou

casperjs css selector exists but when click it raise "CasperError: Cannot dispatch mousedown event on nonexistent selector"

本文关键字:选择器 CasperError 不存在 mou 调度 存在 单击 casperjs-css      更新时间:2023-09-26

我的代码:

var search_selector = "a[href*='id=40076700745']";
casper.then(function(){
    if (this.exists(search_selector)) {
        this.wait(1000, function(){
            this.click(search_selector);
        });
    }
}

我使用exists来检查选择器是否存在,但当单击它时,casper会给我一个错误。

这似乎是PhantomJS中的一个半确认错误:https://github.com/n1k0/casperjs/issues/378

建议使用SlimerJS,或者使用XPath选择器。既然PhantomJS 2.0已经发布,我也建议尝试一下;也许Phantom 1.x的href*=选择器有问题?

(当然,如果你也可以在SlimerJS中复制它,那么就制作一个测试用例,如上面的bug问题所示,并将其作为casperJS bug提交。)