Skip to content
hekra01 edited this page Oct 31, 2017 · 58 revisions

Docker

  • For the dockerized QtWebDriver see Docker, otherwise, to build manually, see below.

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

On Windows, you will need MSVC and gyp: https://chromium.googlesource.com/external/gyp

  • Clone QtWebdriver
$ git clone https://github.com/cisco-open-source/qtwebdriver
$ cd qtwebdriver
  • Create a configuration file wd.gypi, e.g:
# copy a sample configuration file and adjust paths 
$ cp qt5_sample_config.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 QtWebkit. Set to '0' on Qt >= 5.6 or for widget only builds
    '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'
 },
}

Note: If using Qt versions >= 5.6, in which QtWebkit and QWebView support is removed, then WD_CONFIG_WEBKITshould be set to 0 in order to build. QtWebdriver only supports QtWidget and QML for such versions.

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

See Use QtWebDriver to run your application

Check it works

To check if the WebDriver server is running you can send an HTTP GET request to /status on the configured port (9517 by default). For example with curl you can run:

$ curl localhost:9517/status
{"status":0,"value":{"build":{"revision":"WebDriver-cisco-cmt-1.3.0-64-gaadf6acdee","time":"Marversion":"1.3.3"},"os":{"arch":"x86_64","name":"Linux","version":"4.4.0-66-generic"}}}