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

Node#click is flaky? #76

Open
YusukeIwaki opened this issue May 27, 2021 · 2 comments
Open

Node#click is flaky? #76

YusukeIwaki opened this issue May 27, 2021 · 2 comments

Comments

@YusukeIwaki
Copy link

When I tried this Gem with the example spec below, Apprition driver passes only 8/10 where capybara selenium driver passes 10/10.

RSpec.describe 'github search' do
  around do |example|
    prev_host = Capybara.app_host
    Capybara.app_host = 'https://github.com'
    begin
      example.run
    ensure
      Capybara.app_host = prev_host
    end
  end

  10.times { # repeat and repeat and repeat...!!
  it 'should search repository' do
    visit '/'

    fill_in('q', with: 'selenium')
    find('a[data-item-type="global_search"]').click

    output = all('.repo-list-item').map do |li|
      li.all('a').first.text
    end
    puts output
    expect(output).to include(match(/selenium/i))
  end
  }

end
Failures:

  1) github search should search repository
     Failure/Error: find('a[data-item-type="global_search"]').click
     
     Capybara::ElementNotFound:
       Unable to find visible css "a[data-item-type=\"global_search\"]"
     # ./spec/feature/github_search_spec.rb:44:in `block (2 levels) in <top (required)>'
     # ./spec/feature/github_search_spec.rb:8:in `block (2 levels) in <top (required)>'

  2) github search should search repository
     Failure/Error: find('a[data-item-type="global_search"]').click
     
     Capybara::ElementNotFound:
       Unable to find visible css "a[data-item-type=\"global_search\"]"
     # ./spec/feature/github_search_spec.rb:70:in `block (2 levels) in <top (required)>'
     # ./spec/feature/github_search_spec.rb:8:in `block (2 levels) in <top (required)>'

The link is shown only during the text field is focused.

image

@YusukeIwaki
Copy link
Author

Actually I found this problem in my Capybara driver development (capybara-playwright-driver).
This issue is also reproduced with cuprite.

I don't know detailed cause but it seems that visible? checks the node visibility with JS, which can be evaluated without attached to the DOM. So I avoided this problem by adding an assertion of node staleness, before executing JS for checking visibility.
YusukeIwaki/capybara-playwright-driver#31

@nathan-appere
Copy link

Related: got bitten by Bootstrap 5 default scroll-behavior: smooth; when focusing on inputs!

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

2 participants