thoughtbot / capybara-webkit

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

Support for QT 5.6 #885

Closed nritholtz closed 8 years ago

nritholtz commented 8 years ago

I am trying to get around an issue that seems to be fixed in the brew version of QT 5.5.1 (I believe they call it 5.5.1_2), but not on the regular download versions for Linux machines. I believe it's related to a patch in brew, that should be included in the next QT release.

So I tried to download the 5.6 Beta on my Ubuntu 14.04.1 and reinstall capybara-webkit to see if it fixed the issue. However, I am getting the following output:

$ gem install capybara-webkit -v '1.8.0'
Building native extensions.  This could take a while...
ERROR:  Error installing capybara-webkit:
    ERROR: Failed to build gem native extension.

    /home/vagrant/.rvm/rubies/ruby-2.1.0/bin/ruby -r ./siteconf20160308-1091-hfln92.rb extconf.rb
cd src/ && ( test -e Makefile.webkit_server || /opt/qt56/bin/qmake /home/vagrant/.rvm/gems/ruby-2.1.0@automated_testing/gems/capybara-webkit-1.8.0/src/webkit_server.pro -o Makefile.webkit_server ) && make -f Makefile.webkit_server 
Project ERROR: Unknown module(s) in QT: webkitwidgets
make: *** [sub-src-webkit_server-pro-make_first-ordered] Error 3
Command 'make' failed

make "DESTDIR=" clean
cd src/ && ( test -e Makefile.webkit_server || /opt/qt56/bin/qmake /home/vagrant/.rvm/gems/ruby-2.1.0@automated_testing/gems/capybara-webkit-1.8.0/src/webkit_server.pro -o Makefile.webkit_server ) && make -f Makefile.webkit_server clean
Project ERROR: Unknown module(s) in QT: webkitwidgets
make: *** [sub-src-webkit_server-pro-clean-ordered] Error 3

make "DESTDIR="
cd src/ && ( test -e Makefile.webkit_server || /opt/qt56/bin/qmake /home/vagrant/.rvm/gems/ruby-2.1.0@automated_testing/gems/capybara-webkit-1.8.0/src/webkit_server.pro -o Makefile.webkit_server ) && make -f Makefile.webkit_server 
Project ERROR: Unknown module(s) in QT: webkitwidgets
make: *** [sub-src-webkit_server-pro-make_first-ordered] Error 3

make failed, exit code 2

Gem files will remain installed in /home/vagrant/.rvm/gems/ruby-2.1.0@automated_testing/gems/capybara-webkit-1.8.0 for inspection.
Results logged to /home/vagrant/.rvm/gems/ruby-2.1.0@automated_testing/extensions/x86_64-linux/2.1.0/capybara-webkit-1.8.0/gem_make.out

General google searches are telling me to make sure libqt5webkit5-dev is installed, but it is, and it's the latest.

$ sudo apt-get install libqt5webkit5-dev -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libqt5webkit5-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 35 not upgraded.

For simplicity sake, the way I installed the 5.6 Beta was:

sudo add-apt-repository ppa:beineri/opt-qt56-beta-trusty -y
sudo apt-get update -y
sudo apt-get install qt56base -y 
source /opt/qt56/bin/qt56-env.sh

Then the verification:

$ qmake -v
QMake version 3.0
Using Qt version 5.6.0 in /opt/qt56/lib

Any ideas? I do notice that the installation process explicitly asks for this resource

mhoran commented 8 years ago

Hey @nritholtz. Unfortunately Qt 5.5 is the last version of Qt that capybara-webkit will support. The Qt project has dropped the WebKit bindings from binary releases in 5.6. While the bindings can still be manually compiled, there will be no further updates to QtWebKit.

The replacement, QtWebEngine, provides bindings against Chromium. However, QtWebEngine is not a drop-in replacement for QtWebKit, and it would be extremely difficult to port capybara-webkit to work with the new asynchronous API, if not impossible.

We've kicked off an effort to port capybara-webkit to Chromum Embedded. CEF provides a stable API to Chromium, and exposes more of the Chromium/Blink API than QtWebEngine. It also removes the dependency we've had on Qt in the past, simplifying compilation and dependency management.

For now, you'll have to stick with Qt 5.5 and capybara-webkit. I wouldn't recommend trying to compile Qt 5.6 with QtWebKit enabled, as this would be a completely unsupported configuration. I'll keep you posted as the CEF port progresses. Right now I'm waiting for the "Out Of Process Iframes" refactoring to complete, which would require a rewrite of some of the code that's slated to be written next.

jferris commented 8 years ago

It probably makes sense for us to update the version checking we have to bail on Qt 5.6 with an explanation.

rgreenjr commented 8 years ago

I ran into this problem too and couldn't figure it out until I found this post. I agree with @jferris that a warning/explanation would be helpful.

ryanwjackson commented 8 years ago

Running into this now (and agree with @rgreenjr and @jferris). I'm on a mac using Homebrew. How can I install qt 5.5.0 or 5.5.1? I can't seem to find a tap for it anywhere.

rgreenjr commented 8 years ago

@ryanwjackson Here's how I was able to install qt 5.5.

brew install https://raw.githubusercontent.com/Homebrew/homebrew/f802822b0fa35ad362aebd0101ccf83a638bed37/Library/Formula/qt5.rb

brew link --force qt5

mhoran commented 8 years ago

Thanks for the instructions, @rgreenjr. None of the maintainers use OS X, so it can be difficult at times for us to help out users on different platforms. It'd be great if you could add this to the wiki so that we can point others to your findings.

rgreenjr commented 8 years ago

@mhoran Sure I'd be happy to. I just updated the wiki the correct steps.

number5 commented 8 years ago

FYI Homebrew guys have added QT 5.5 to homebrew/versions tap , so there are better way to install qt5.5 via homebrew

brew tap homebrew/versions
brew install qt55
brew link --force qt55

Noted that the path like /usr/local/opt/qt5/bin/qmake needs to change to /usr/local/opt/qt55/bin/qmake

rgreenjr commented 8 years ago

Thanks @number5. I looked for a qt55 formula this morning, but it didn't exist yet. I'll update the wiki.

mhoran commented 8 years ago

capybara-webkit will now raise a more meaningful error when compiled with Qt > 5.5

mathieujobin commented 8 years ago

I am so sad ! Plasma desktop 5.6 just came out ... I'm gonna need a different linux box just for this

olivierlacan commented 7 years ago

@mhoran Any news on the CEF effort?

nnc commented 7 years ago

@olivierlacan I was wondering about that myself, and would also love an update!

However, it was previously said the CEF version is waiting for completion of "Out Of Process Iframes", which is still ongoing in the Chromium itself, it seems. See this CEF ticket for more info.

mhoran commented 7 years ago

Hey @olivierlacan, thanks for checking on this. I'd put down my work on capybara-chromium for a bit due to the OOP iframe issue as @nnc noted. However, this process is still ongoing, and I know folks are looking for an alternative. @mike-burns and I plan to pick up the effort again sometime soon. I'll keep you posted!

prusswan commented 7 years ago

Unfortunate, but looks like it would be down to just :poltergeist in time to come

mike-burns commented 7 years ago

I recommend the :chrome driver. Here's an example of setting it up: https://mikecoutermarsh.com/rails-capybara-selenium-chrome-driver-setup/

MrJoy commented 7 years ago

"While the bindings can still be manually compiled, there will be no further updates to QtWebKit." <-- Source? NM on this. I'm caught up on that aspect now. However...

It appears to an me like QtWebKit is still being maintained -- there are active branches corresponding to current Qt versions (as recent as 5.9). As an OSX user I've had zero problems as recently as Qt 5.8 when installing with brew install qt --with-qtwebkit using capybara-webkit.

On the other hand, my coworkers using Qt 5.5.x seem to encounter random hangs that I have yet to encounter. This is making the don't-use-qt-past-5.5 thing a bit worrisome.

Thoughts?

jferris commented 7 years ago

According to the Qt project, QtWebKit was deprecated in 5.5 and removed in 5.6 (but still available to compile from source).

There is a post on the Qt blog which states:

While we no longer will do any feature development in Qt WebKit, the existing version will continue to be available.

MrJoy commented 7 years ago

Yes, I understand that. I also suspect they won't be continuing that work into Qt 5.10 based on the absence of a QtWebKit branch of that name.

My concern is that there is what may be an issue in Qt 5.5.x affecting my team and our use of capybara-webkit, that appears to be fixed by moving to a newer Qt (compiled with QtWebKit) -- but we are nervous about doing that because you guys still recommend sticking with Qt 5.5.x.

Beyond the deprecation of QtWebKit, and the overhead of having to go out of one's way to include QtWebKit when building Qt > 5.5.x, how would you guys handle any issues that come up in such a configuration? Are we just totally on our own?

Perhaps a more plain way of expressing what I'm asking is: Does the apparent ongoing development of QtWebKit to maintain compatibility with Qt 5.6-5.9 affect your plans in terms of supported configurations?

mhoran commented 7 years ago

Hey @MrJoy, sorry for the delay. My opinion is that, so long as you can find a working distribution of Qt > 5.5 with a WebKit that works, then that's fine. It does look like there's a community effort to revive the QtWebKit project, though I'm not sure that' is intended to merge back into the mainline Qt code base. So if you've found that your issues are resolved with Qt > 5.5, then go for it!

bertrandmoulard commented 7 years ago

Hello @mhoran! Any news on the switch to CEF?

mhoran commented 7 years ago

Hey @bertrandmoulard! The CEF port has stalled, mostly due to lack of time. I wish I had better news -- I got about half of the test cases passing, and I think most of the hard stuff is out of the way. There was a bit of "works on my machine" to get over and, well, I never got too far past that.

bertrandmoulard commented 7 years ago

Thank you (a little late) for getting back to me @mhoran. Let's hope that QT will prove to be a durable solution.

jeremywadsack commented 7 years ago

@number5's suggestion to install qt55 on homebrew has changed. You no longer need to tap fomulae.

The following worked for me.

brew uninstall qt        # if you had it previously installed
brew install qt55
gem uninstall capybara-webkit
QMAKE=/usr/local/Cellar/qt@5.5/5.5.1_1/bin/qmake bundle install

The path may be different if there's an updated version of qt released. You can find the path from the last line of the brew install command:

==> Summary
🍺  /usr/local/Cellar/qt@5.5/5.5.1_1: 7,330 files, 330.5MB
number5 commented 7 years ago

@jeremywadsack thanks for the updates.

The always working path for qt55 will be /usr/local/opt/qt@5.5/bin/qmake So if 5.5.1_2 come out it will be still linked to /usr/local/opt/qt@5.5

you can find out more by running brew info qt55

elsiddh commented 7 years ago

Using the method of @jeremywadsack i got the following:

`Building native extensions. This could take a while... ERROR: Error installing capybara-webkit: ERROR: Failed to build gem native extension.

/Users/sid/.rbenv/versions/2.0.0-p247/bin/ruby extconf.rb

Info: creating stash file /Users/sid/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capybara-webkit-0.11.0/.qmake.stash cd src/ && ( test -e Makefile.webkit_server || /usr/local/Cellar/qt@5.5/5.5.1_1/bin/qmake /Users/sid/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capybara-webkit-0.11.0/src/webkit_server.pro -spec macx-g++ -o Makefile.webkit_server ) && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f Makefile.webkit_server /Applications/Xcode.app/Contents/Developer/usr/bin/g++ -c -pipe -O2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.7 -Wall -W -fPIC -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtWebKit.framework/Headers -I/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtGui.framework/Headers -I/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtNetwork.framework/Headers -I/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/AGL.framework/Headers -I/usr/local/Cellar/qt@5.5/5.5.1_1/mkspecs/macx-g++ -F/usr/local/Cellar/qt@5.5/5.5.1_1/lib -o CurrentUrl.o CurrentUrl.cpp In file included from CurrentUrl.cpp:2: ./WebPage.h:3:24: error: base class has incomplete type class WebPage : public QWebPage {


/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtWebKit.framework/Headers/qwebelement.h:157:18: note: forward declaration of 'QWebPage'
    friend class QWebPage;
                 ^
In file included from CurrentUrl.cpp:2:
./WebPage.h:17:29: error: unknown type name 'Extension'
    virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
                            ^
./WebPage.h:17:56: error: unknown type name 'ExtensionOption'; did you mean 'QWebPluginFactory::ExtensionOption'?
    virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
                                                       ^~~~~~~~~~~~~~~
                                                       QWebPluginFactory::ExtensionOption
/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtWebKit.framework/Headers/qwebpluginfactory.h:61:11: note: 'QWebPluginFactory::ExtensionOption' declared here
    class ExtensionOption
          ^
In file included from CurrentUrl.cpp:2:
./WebPage.h:17:83: error: unknown type name 'ExtensionReturn'; did you mean 'QWebPluginFactory::ExtensionReturn'?
    virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
                                                                                  ^~~~~~~~~~~~~~~
                                                                                  QWebPluginFactory::ExtensionReturn
/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtWebKit.framework/Headers/qwebpluginfactory.h:63:11: note: 'QWebPluginFactory::ExtensionReturn' declared here
    class ExtensionReturn
          ^
CurrentUrl.cpp:58:13: error: no member named 'currentFrame' in 'WebPage'
    page()->currentFrame()->url() : page()->currentFrame()->requestedUrl();
    ~~~~~~  ^
CurrentUrl.cpp:58:45: error: no member named 'currentFrame' in 'WebPage'
    page()->currentFrame()->url() : page()->currentFrame()->requestedUrl();
                                    ~~~~~~  ^
CurrentUrl.cpp:65:18: error: no member named 'currentFrame' in 'WebPage'
  return page()->currentFrame()->url() == page()->currentFrame()->requestedUrl();
         ~~~~~~  ^
CurrentUrl.cpp:65:51: error: no member named 'currentFrame' in 'WebPage'
  return page()->currentFrame()->url() == page()->currentFrame()->requestedUrl();
                                          ~~~~~~  ^
CurrentUrl.cpp:69:39: error: no member named 'currentFrame' in 'WebPage'
  return !wasRegularLoad() && page()->currentFrame()->url() == page()->history()->currentItem().url();
                              ~~~~~~  ^
CurrentUrl.cpp:69:72: error: no member named 'history' in 'WebPage'
  return !wasRegularLoad() && page()->currentFrame()->url() == page()->history()->currentItem().url();
                                                               ~~~~~~  ^
10 errors generated.
make[1]: *** [CurrentUrl.o] Error 1
make: *** [sub-src-webkit_server-pro-make_first-ordered] Error 2

make "DESTDIR="
cd src/ && ( test -e Makefile.webkit_server || /usr/local/Cellar/qt@5.5/5.5.1_1/bin/qmake /Users/sid/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capybara-webkit-0.11.0/src/webkit_server.pro -spec macx-g++ -o Makefile.webkit_server ) && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f Makefile.webkit_server 
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -c -pipe -O2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.7 -Wall -W -fPIC -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtWebKit.framework/Headers -I/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtGui.framework/Headers -I/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtNetwork.framework/Headers -I/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/AGL.framework/Headers -I/usr/local/Cellar/qt@5.5/5.5.1_1/mkspecs/macx-g++ -F/usr/local/Cellar/qt@5.5/5.5.1_1/lib -o CurrentUrl.o CurrentUrl.cpp
In file included from CurrentUrl.cpp:2:
./WebPage.h:3:24: error: base class has incomplete type
class WebPage : public QWebPage {
                ~~~~~~~^~~~~~~~
/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtWebKit.framework/Headers/qwebelement.h:157:18: note: forward declaration of 'QWebPage'
    friend class QWebPage;
                 ^
In file included from CurrentUrl.cpp:2:
./WebPage.h:17:29: error: unknown type name 'Extension'
    virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
                            ^
./WebPage.h:17:56: error: unknown type name 'ExtensionOption'; did you mean 'QWebPluginFactory::ExtensionOption'?
    virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
                                                       ^~~~~~~~~~~~~~~
                                                       QWebPluginFactory::ExtensionOption
/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtWebKit.framework/Headers/qwebpluginfactory.h:61:11: note: 'QWebPluginFactory::ExtensionOption' declared here
    class ExtensionOption
          ^
In file included from CurrentUrl.cpp:2:
./WebPage.h:17:83: error: unknown type name 'ExtensionReturn'; did you mean 'QWebPluginFactory::ExtensionReturn'?
    virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
                                                                                  ^~~~~~~~~~~~~~~
                                                                                  QWebPluginFactory::ExtensionReturn
/usr/local/Cellar/qt@5.5/5.5.1_1/lib/QtWebKit.framework/Headers/qwebpluginfactory.h:63:11: note: 'QWebPluginFactory::ExtensionReturn' declared here
    class ExtensionReturn
          ^
CurrentUrl.cpp:58:13: error: no member named 'currentFrame' in 'WebPage'
    page()->currentFrame()->url() : page()->currentFrame()->requestedUrl();
    ~~~~~~  ^
CurrentUrl.cpp:58:45: error: no member named 'currentFrame' in 'WebPage'
    page()->currentFrame()->url() : page()->currentFrame()->requestedUrl();
                                    ~~~~~~  ^
CurrentUrl.cpp:65:18: error: no member named 'currentFrame' in 'WebPage'
  return page()->currentFrame()->url() == page()->currentFrame()->requestedUrl();
         ~~~~~~  ^
CurrentUrl.cpp:65:51: error: no member named 'currentFrame' in 'WebPage'
  return page()->currentFrame()->url() == page()->currentFrame()->requestedUrl();
                                          ~~~~~~  ^
CurrentUrl.cpp:69:39: error: no member named 'currentFrame' in 'WebPage'
  return !wasRegularLoad() && page()->currentFrame()->url() == page()->history()->currentItem().url();
                              ~~~~~~  ^
CurrentUrl.cpp:69:72: error: no member named 'history' in 'WebPage'
  return !wasRegularLoad() && page()->currentFrame()->url() == page()->history()->currentItem().url();
                                                               ~~~~~~  ^
10 errors generated.
make[1]: *** [CurrentUrl.o] Error 1
make: *** [sub-src-webkit_server-pro-make_first-ordered] Error 2

Gem files will remain installed in /Users/sid/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capybara-webkit-0.11.0 for inspection.
Results logged to /Users/sid/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capybara-webkit-0.11.0/./gem_make.out
`