thoughtbot / capybara-webkit

A Capybara driver for headless WebKit to test JavaScript web apps
https://thoughtbot.com/open-source
MIT License
1.97k stars 427 forks source link

capybara-webkit fails on docker alpine with qt5 #983

Closed kdiogenes closed 7 years ago

kdiogenes commented 7 years ago

I'm using capybara-2.4.4 and capybara-webkit-1.12.0 building on ruby:2.2.4-alpine. If I use qt4 everything works okay, but the wiki says that qt5 is the recommended version, so I'm opening this to try to find a solution.

Capybara is able to use capybara-webkit to load the page, it can even save the page, but the interactions doesn't works. I also noted that current_path doesn't change.

This is a little script that shows the problem and below is the saved screenshot:

Capybara::Webkit.configure do |config|
  config.debug = true
  config.allow_unknown_urls
end
Headless.new.start
s = Capybara::Session.new(:webkit)
s.visit('http://google.com')
s.save_screenshot('tmp/test.png')
s.click_link('Fazer login')
Capybara::ElementNotFound: Unable to find link "Fazer login"
    from /usr/local/bundle/gems/capybara-2.4.4/lib/capybara/node/finders.rb:41:in `block in find'
    from /usr/local/bundle/gems/capybara-2.4.4/lib/capybara/node/base.rb:84:in `synchronize'
    from /usr/local/bundle/gems/capybara-2.4.4/lib/capybara/node/finders.rb:30:in `find'
    from /usr/local/bundle/gems/capybara-2.4.4/lib/capybara/node/actions.rb:27:in `click_link'
    from /usr/local/bundle/gems/capybara-2.4.4/lib/capybara/session.rb:676:in `block (2 levels) in <class:Session>'
    from (irb):10
    from /usr/local/bundle/gems/railties-4.2.4/lib/rails/commands/console.rb:110:in `start'
    from /usr/local/bundle/gems/railties-4.2.4/lib/rails/commands/console.rb:9:in `start'
    from /usr/local/bundle/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /usr/local/bundle/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /usr/local/bundle/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
    from /usr/local/bundle/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
    from /usr/local/bundle/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
    from /usr/local/bundle/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /usr/local/bundle/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
    from /var/www/alfaconrails/bin/rails:8:in `<top (required)>'
    from /usr/local/bundle/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `load'
    from /usr/local/bundle/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `block in load'
    from /usr/local/bundle/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /usr/local/bundle/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `load'
    from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'

test

webattitude commented 7 years ago

alpine has now qt 5.6, which does not work I suggest readme should be modified How can we use latest alpine so we can deploy all this on kubernetes ?

jferris commented 7 years ago

The README says:

If you're having trouble compiling or installing, please check out the wiki. If you don't have any luck there, please post to Stack Overflow. Please don't open a Github issue for a system-specific compiler issue.

You can check out the Wiki here: https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit

We rely on the community to update those instructions for compiling on various systems, as the maintainers don't have the bandwidth to debug compiling on every system.

In general, many distributions have a separate package for qtwebkit, even on qt 5.6. If alpine doesn't, you'll have to compile Qt with the webkit module enabled.

kdiogenes commented 7 years ago

@webattitude I also think that the information about qt version must be more explicit.

In the wiki there is a mention about no support for qt 5.6 https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit#homebrew

There is also comments about this is some bug reports: https://github.com/thoughtbot/capybara-webkit/issues/984#issuecomment-302122527

The README don't mention anything about this, but from @jferris comment and this commit I understand that capybara-webkit should work with qt 5.6: https://github.com/thoughtbot/capybara-webkit/commit/0af3c34aa6d80581f59ceb8a5fb8fcb6d3e95dd9

I will give it another try...