π Parent Note
π€ Situation
Let's suppose that you have a panel and test it's changed from open to closed.
π Bad code
expect(find('div.target > div.message', visible: false).visible?).to eq true find('div.target').click # the panel will be closed. expect(find('div.target > div.message', visible: false).visible?).to eq false # Error because Capybara is too fast π # --- # Failure/Error # expected: false # got: true πGood code
Let's use Capybara::RSpecMatchers#have_selector.
Then, Capybara waits the animation until the test is green.
expect(find('div.target').to have_selector('div.message') find('div.target').click expect(find('div.target').not_to have_selector('div.message')
Top comments (0)