mercredi 17 mai 2017

Capybara test intermittently failing when using Selenium driver

I've got an integration test here which is passing flawlessly using the poltergeist driver every time, but when I run this test using Selenium it passes on average 3 times and fails 1 time.

def fill_in_inclusion_criteria
  find("div.measure#age label[for='16']").click
  find("div.measure#substance_use_met label[for='1']").click
  find("div.measure#participant_consent label[for='1']").click
  click_link("Next")
end

When it fails, the error that I get back is this

expected to find css "div.measure#participant_consent" but there were no matches. Also found "", which matched the selector but not all filters.

The participant consent button appears when div.measure#age label[for='16'] is clicked, so it's dependent on Javascript. I see this happening in Firefox most of the time, but when it errors, the div isn't visible on the page.

It seems like it's not waiting for the element to display on the page before clicking it, but I thought that wrapping it in a "find" waits for the element to be visible on the page before trying to click it?

Any idea why this could be happening?

Aucun commentaire:

Enregistrer un commentaire