Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visibility issue upon replacing hidden nodes (Race condition) #239

Open
stevschmid opened this issue Jun 21, 2023 · 0 comments
Open

Visibility issue upon replacing hidden nodes (Race condition) #239

stevschmid opened this issue Jun 21, 2023 · 0 comments

Comments

@stevschmid
Copy link

stevschmid commented Jun 21, 2023

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.

@stevschmid stevschmid changed the title Visibility issue upon replacing hidden nodes (Race condition with Capybara) Visibility issue upon replacing hidden nodes (Race condition) Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant