Open
Description
I noticed the following: If you replace hidden content of a hidden parent (e.g. using innerHTML
) and then make the parent visible, Capybara intermittently picks up the old content.
I was able to create this very minimal HTML with the accompanying, random failing spec:
<!-- test.html -->
<button onclick="document.querySelector('#editor').style.display = 'none'">Hide</button>
<button onclick="setTimeout(() => { document.querySelector('#editor').innerHTML = '<textarea name=draft></textarea>'; document.querySelector('#editor').style.display = 'block'; }, 100);">Reset</button>
<div id=editor>
<textarea name=draft></textarea>
</div>
# test.rb
scenario 'flaky spec' do
visit '/test.html'
click_on 'Hide'
expect(page).not_to have_field('draft')
click_on 'Reset'
fill_in 'draft', with: 'World'
expect(page).to have_field('draft', with: 'World')
end
Testing this multiple times using while bin/rspec spec/features/test.rb; do :; done
leads quickly to
Failure/Error: expect(page).to have_field('draft', with: 'World')
expected to find field "draft" that is not disabled with value "World" but there were no matches. Also found "", which matched the selector but not all filters. Expected value to be "World" but was ""
Tested both with the most recent gem version as well as github master.
I will submit a PR with a potential fix.
Update: After further investigation, this seems to be an issue in Ferrum. I will open the PR there and reference this issue.
Metadata
Metadata
Assignees
Labels
No labels