我不明白,为什么 mouse::move()
不起作用。例如this page .
正如您所看到的,共有10个元素,将鼠标光标移动到每张图片上后您将看到详细信息。我有一组每个元素的 id。我想将光标移动到每个元素上,然后选择器“div#hover_item_descriptors”将被更新,我将使用它。这是我的代码:
this.eachThen(ids, function(resp){
var id = resp.data;
this.then(function(){
this.mouse.move('span#' + id + '_name'); //moving at the name of element
});
this.waitUntilVisible('div#hover_item_descriptors div#sticker_info', function(){
// it`s never work, because moving doesn't work
});
});
为什么不起作用?
最佳答案
我也偶然发现了这一点,由于这个问题而弄清楚了:https://github.com/n1k0/casperjs/issues/208
事实证明,如果您将光标悬停在不在视口(viewport)中的元素上,悬停事件将不起作用。
因此,要使其正常工作,请设置保证超过页面高度的视口(viewport)高度,例如:
var casper = require('casper').create({
viewportSize : { width: 1280, height: 5000 }
});
关于javascript - CasperJS 中移动鼠标触发悬停事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33858372/