Error when running specs: Poltergeist detected ano

2019-03-31 18:27发布

问题:

I added activeadmin in my Gemfile.

I ran:

rails g active_admin:install Admin User
rake db:migrate

Then I ran:

bundle exec rake test:integrations

and I got this error:

Capybara::Poltergeist::ClickFailed:
Click at co-ordinates [330.5, 714] failed. Poltergeist detected another element 
with CSS selector 'html body div#ui-datepicker-div.ui-datepicker.ui-widget.ui-widget-content.ui-helper-clearfix.ui-corner-all div.ui-datepicker-header.ui-widget-header.ui-helper-clearfix.ui-corner-all div.ui-datepicker-title span.ui-datepicker-month' 
at this position. It may be overlapping the element you are trying to click.

I tried excluding the activeadmin js and css as recommended in this post, but I still get the error.

Does anyone have any ideas of how to solve this?

回答1:

I am assuming the message is from a failing capybara step. I ran into this issue today when using the following against an ajax form:

find('some-css').click()

Unfortunately on occasion it was returning the very frustrating overlapping css error. What I did was to use this method instead:

find('some-css').trigger('click')

And hey presto works every time :)

Hope this helps.



回答2:

I was getting this bug because I tested a hover and then needed to click on the link underneath the tooltip. The solution was to add page.find('.sp-logo').hover before click_link to get the tooltip out of the way.



回答3:

I had another bug where find_link on Chrome and Poltergeist could not click an A tag with an EM tag and some text inside of it, although it worked fine in Firefox and rack_test. The solution was to replace click_link(link) with find('a em', text: link).click. Unfortunately, this doesn't work on rack_test, resulting in this hack:

When /^I click the emphasized text "([^\"]*)"$/ do |link|
  if Capybara.current_driver == :rack_test
    click_link(link)
  else
    find('a em', text: link).click
  end
end


回答4:

In my case, wanted to test a second click - forgot about a modal showing after the first click. Found it after reading the massive CSS selector to the end.

detected another element with CSS selector
'html.js...alotofotherclasses...div.sweet-alert.show-sweet-alert.visible'

Solved it by dismissing it - so basically - just read the message carefully.

click_button I18n.t('mail_form.submit')
expect(page).to have_content I18n.t('mail_form.flash.submitted')
click_button I18n.t('alert.ok')