Skip to content
hekra01 edited this page Oct 30, 2016 · 58 revisions

Build

  • Required tools:
    • Python 2.7.2+
    • Qt 4.8.2+ or Qt 5.x

Example build in Ubuntu 14.04:

  • Install dependencies:
    $ sudo apt-get install g++ gyp
  • Clone QtWebdriver
$ git clone https://github.com/cisco-open-source/qtwebdriver
$ cd qtwebdriver
  • Create a configuration file wd.gypi, e.g:
# copy wd_common.gypi then edit it and adjust paths 
$ cp wd_common.gypi wd.gypi
$ vi
# ...edit, e.g: 
$ cat wd.gypi
{
'variables': {
    'QT5': '1', # change to '0' to disable Qt5
    'WD_CONFIG_QWIDGET_BASE': '1', # 1 to support widget or hybrid web
    'WD_CONFIG_WEBKIT': '1', #1 to support Web views
    'WD_CONFIG_QUICK': '1', #1 to support QML
    'WD_BUILD_MONGOOSE': '1', #1 to inline mongoose code in WebDriver libraries. Leave as is.
    'WD_CONFIG_PLAYER': '0', #For Qt5 only. If the Qt build includes QtMultimedia, then setting this field to 1 will enable to driving QMediaPlayer. See https://github.com/cisco-open-source/qtwebdriver/wiki/Media-Commands
    'WD_CONFIG_ONE_KEYRELEASE': '0', # Set to 0 (default). On long key press WD will send as many key release as key press. If set to 1 only the final key release is sent
    'QT_INC_PATH': '/home/user/Qt/5.2.0/gcc_64/include',
    'QT_BIN_PATH': '/home/user/Qt/5.2.0/gcc_64/bin',
    'QT_LIB_PATH': '/home/user/Qt/5.2.0/gcc_64/lib'
 },
}

Sample configuration files here, for Qt5 and Qt4

  • Build:
$ ./build.sh ./out

# The binaries are here:
# The WebDriver binary can automate QtWebkit, Qwidget, QML applications
$ ls -l  out/bin/desktop/release/WebDriver

# The WebDriver_noWebkit is the same, except without QtWebkit support.
$ ls -l  out/bin/desktop/release/WebDriver_noWebkit
  • Note 1: on Windows, build.bat will create a msvc project in out\wd.sln that should then be built in msvc.
  • Note 2: QtWebDriver is not supported on QT versions >= 5.6, in which QtWebkit views are removed.
  • Note 3: For webdriver support on QWebEngine, use the ChromeDriver included in QWebEngine.

Run

To run the prebuilt binaries

On Windows
# Set Qt environment, for Qt5
D:\test> D:\Qt\5.2.1\msvc2010_opengl\bin\qtenv2.bat vsvars
# Or for Qt4
D:\Qt\4.8.6\bin\qtvars.bat vsvars

# Then run WebDriver
D:\test> WebDriver.exe
On Linux
# Set Qt environment
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/Qt/5.2.0/gcc_64/lib

# Run WebDriver
$ cd WebDriver-linux64-Qt5.2.0-cisco-cmt-1.3.0/bin/
$ ./WebDriver

By default QtWebdriver starts on port 9517. To change this or use more options see Command Line Switches.

Once QtWebdriver is started, use a Selenium client to connect to it and automate Qt applications.

See Releases to download the pre-built exes

To build and run your own binary

In order to use QtWebDriver with your existing application you nee dto start if from the main of your app.

Supposing you already have prebuilt the libraries of QtWebDriver, you can use them in you app like this:

/**
 * This can be used as a template to insert QtWebDriver in an application code
 * QtWebdriver shoud be started in the same process as the QApplication
 */
#include "Headers.h"

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    /* 
      Here goes more of the application specific code ...
    */
   
    /* Then setup and start webdriver */
    int startError = wd_setup(argc, argv);
    if (startError){
        std::cout << "Error while starting server, errorCode " << startError << std::endl;
        return startError;
    }

    return app.exec();
}
  • Rebuild your application
  • Run you application as usual. QtWebDriver will be started as well and listening on port 9517 by default
  • Then use Selenium or WebDriverJS to test your application
  • See Command Line Switches for the command line arguments supported by QtWebDriver.
Clone this wiki locally