gucki
gucki

Reputation: 4772

capybara with selenium wait for onchange event

I have a form field with an onchange event which inserts some text into the page.

fill_in "password", :with => 'test' # should trigger onchange which inserts the text below into the page
page.should have_content('very insecure')

Now when I test this with cucumber/ capybara/ selenium with firefox it works without any problems. Using selenium with chrome, capybara complains the text is not found in the document.

Now I wonder how to fix this. Do I need to manually invoke the event (which would be real hacky imo)? Or do I simply have to wait for all events being processed (how?) between my fill_in and should have_content methods?

Upvotes: 3

Views: 1218

Answers (1)

Bob Roberts
Bob Roberts

Reputation: 1021

If you feel that it is an issue that you need to wait longer, I would throw in a "sleep 3" before the page.should. There are also raw Selenium commands for this but it is best to avoid them.

Upvotes: -1

Related Questions