Begin use qtwebdriver with Qt-propgramm
KondrikA opened this issue · 4 comments
Hello
Please, prompt some nuances on beginning testing Qt-program. I am trying to do this on Windows.
I downloaded the source code cisco-open-source / qtwebdriver, launched build.bat. Next, using MSVS gathered wd.sln. The result of the assembly steel two libraries: chromium_base.lib and WebDriver_core.lib.
Next, I need to connect the libraries to the program on Qt and run qtwebdriver at the start of the program?
It would be great to see Qt-HelloWorld minimal program with an example how to start testing it using qtwebdriver.
Hi,
Please check https://github.com/cisco-open-source/qtwebdriver/wiki/Build-And-Run#to-build-and-run-your-own-binary
This page explains and provides example (main.cc) how to include WebDriver in you program.
Basically you shoud start the WebdDriver in themain of you mainapp.
To test the program with an interface on Qt-widgets or QML QtWebDriver need to to embed into the program? If so, for what purpose it used WebDriver.exe?
There are 2 options
Option 1: The WebDriver.exe permits this:
- open html:
driver.get (http://someurl.html) - open qml:
driver.get (http://someurl.qml) - open QtWidget that have been registered with it:
- like here: https://github.com/cisco-open-source/qtwebdriver/blob/WD_1.X_dev/src/Test/main.cc#L305
- then
driver.get (qtwidget://widgetclassname) - This implies the WD will create a new instance of your application. Maybe you don't want this, if so go to option 2
Option 2: use webdriver with an aleady existing app
Then you need to setup WD from the main of you app
- include the headers: https://github.com/cisco-open-source/qtwebdriver/blob/WD_1.X_dev/src/Test/Headers.h
- Call the
wd_setup(argc, argv)function with the parameters you want (See ful argument list: https://github.com/cisco-open-source/qtwebdriver/wiki/Command-Line-Switches) - Some example:
#include "Headers.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// your 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();
}
Thank you very much for your help.