Make capybara wait for an element to disappear
Asked Answered
K

1

8

After a click on some element I expect a placeholder to disappear and another element to appear after an AJAX call is finished.

find(someLocator).click
expect(page).not_to have_css(disappearingPlaceholderLocator)
expect(page).to have_css(appearingElementLocator)

The first expectation fails though and the AJAX call is not executed.

I think this is somehow related to this SO question but I just can't figure out how.

Kimberlite answered 10/2, 2015 at 9:25 Comment(0)
K
4

This works when the expectations are flipped.

find(someLocator).click
expect(page).to have_css(appearingElementLocator)
expect(page).not_to have_css(disappearingPlaceholderLocator)
Kimberlite answered 10/2, 2015 at 9:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.