Poltergeist使用CSS选择器检测到另一个元素

时间:2019-03-20 13:30:11

标签: ruby-on-rails capybara poltergeist

我在用Capybara + Poltergeist抓取仪表板时看到了此错误。我已经尝试了其他帖子中建议的选项,但是还不能使用。

function anim(element, animationName, callback) {
    const node = document.querySelector(element)
    node.classList.add('animated', animationName)

    function handleAnimationEnd() {
        node.classList.remove('animated', animationName)
        node.removeEventListener('animationend', handleAnimationEnd)

        if (typeof callback === 'function') callback()
    }

    node.addEventListener('animationend', handleAnimationEnd)
}

我尝试过的选项

  • 添加window_size时出现相同的错误。坐标(1571.5,584)似乎在选项(1600,1200)中指定的窗口大小之内
Firing a click at co-ordinates [1571.5, 584] failed. Poltergeist detected another element with CSS selector 'html body div#app div.layout div div.dashboard div.dashboard-content div.monitor div.fixed.loading.show' at this position. It may be overlapping the element you are trying to interact with. If you don't care about overlapping elements, try using node.trigger('click').
  • 使用 Capybara.register_driver :poltergeist do |app| Capybara::Poltergeist::Driver.new(app, window_size: [1600, 1200]) end 代替trigger("click")。这不会引发错误,但是无法获得正确的html响应。

有人可以给我一些建议吗?

0 个答案:

没有答案