cisco-open-source / qtwebdriver

WebDriver implementation for Qt
https://github.com/cisco-open-source/qtwebdriver/wiki
197 stars 59 forks source link

Pre-built binaries for Windows version : WebDriver-win64-Qt5.7 ? #41

Closed ReijoSep closed 7 years ago

ReijoSep commented 7 years ago

https://github.com/cisco-open-source/qtwebdriver/releases/tag/WebDriver-cisco-cmt-1.3.3 There are pre-built binaries: Linux-versions: WebDriver-linux64-Qt5.7 WebDriver-linux64-Qt5.6 WebDriver-linux64-Qt5.5

But there is only: Windows version: WebDriver-win64-Qt5.5

I noticed that at first it became Linux version for new QT release and after it will be published Win version….

Questions:

  1. Could it be possible to get WebDriver-win64-QT5.7 version?
  2. Have you any estimation, what kind of delay is between Linux and Windows version of WebDriver pre-built binaries with newer QT release support? I don't know, how complex it is to compile Windows version after Linux version of QTwebdriver?
hekra01 commented 7 years ago

Hi,

1-Updated the release with win binaries. Qt 5.6 & 5.7. Note there is no Qtwebkit support for Qt >= 5.6. If you goal is to automate Qtwebengine, use QtWebEngines ChromeDriver instead. See https://github.com/cisco-open-source/qtwebdriver/issues/31#issuecomment-281014617

2-No release plan or roadmap per se. This project is in maintenance phase. If you want to build from source for specific platform, instructioen are here: https://github.com/cisco-open-source/qtwebdriver/wiki/Build-And-Run

ReijoSep commented 7 years ago

Thanks! There are good instructions (2). If I understood correct, I should change/modify my env variables (path) to point QT environment QT 5.7... and Qtwebkit disabled -> build QTwebdriver project with Microsoft Visual Studio.

hekra01 commented 7 years ago

If I understood correct, I should change/modify

Yes this is correct. When using Qt >= 5.6, disable Qtwebkit by setting in wd_common.gypi:

    'WD_CONFIG_WEBKIT%': '0',

Then build.bat will create the wd.sln that you can open in MSVC and the build the exe. I tested it with MSVC 2013 as qt/5.6 & 5.7 come with libs for this version

ReijoSep commented 7 years ago

I have Windows 7 64-bit Operation System

I would like to test that my environment is ok "WebDriver_noWebkit.exe + QT5.7.0"and after I will build my QT application main.c with

ifdef WD_TEST_APPL_SELENIUM

include "Headers.h"

endif / WD_TEST_APPL_SELENIUM /

ifdef WD_TEST_APPL_SELENIUM

wd_setup(argc, argv);

endif / WD_TEST_APPL_SELENIUM /

and I will add my application configuration file:

define WD_TEST_APPL_SELENIUM

define WD_ENABLE_WEB_VIEW 1

define QT_NO_SAMPLES

I tried to use pre-binary from WebDriver-win-Qt5.7-cisco-cmt-1.3.3.zip.zip from https://github.com/cisco-open-source/qtwebdriver/releases/

  1. I installed QT from http://download.qt.io/official_releases/qt/5.7/5.7.0/
  2. I run qtenv2.bat Command Prompt window: C:\Qt\Qt5.7.0\5.7\msvc2015_64\bin>qtenv2.bat vsvars C:\Qt\Qt5.7.0\5.7\msvc2015_64\bin>echo off Setting up environment for Qt usage... Remember to call vcvarsall.bat to complete environment setup! Note! I didn't find vcvarsall.bat from my PC.
  3. I copied WebDriver_noWebkit to my QT-folder: C:\Qt\Qt5.7.0\5.7\msvc2015_64\bin Note! I tested already C:\Qt\Qt5.7.0\5.7\msvc2013_64\bin with same results.
  4. I tried to run WebDriver_noWebkit.exe I got Application error: kuva

What should I do next? Should I modify some configuration file and build own version from WebDriver_noWebkit.exe with my own configuration? Or is it possible to verify QT environment with WebDriver_noWebkit.exe without QT application? https://github.com/cisco-open-source/qtwebdriver/wiki/Build-And-Run

hekra01 commented 7 years ago

The binaries uploded were 32 bits. To run binaies (regardless 32/64) open a Qt command prompt, (from Programs/Qt/5.7/MSVC2013 (32bit)) and run the exe from there

ReijoSep commented 7 years ago

Thanks. Now I got: kuva

  1. What does it mean: Remeber to call vcvarsall.bat to complete environment setup? Should I do any other settings?

I got also webdriver.log text document. It looks that server starts OK...: [13140793176.579][SEVERE]: Root './web' does not exist!

[13140793176.583][INFO]: * Webdriver ** Version: WebDriver-cisco-cmt-1.3.3 Build Time: May 29 2017 17:08:43

[13140793176.592][FINE]: >>>>>>>>>>>>> Server::Start routes: >>>>>>>>>>>

hekra01 commented 7 years ago

Yes, you're all set and can use wd

What does it mean: Remeber to call vcvarsall.bat to complete environment setup?

No need if you run from Qt command prompt

ReijoSep commented 7 years ago

Where will I find example project for Windows QT application? It looks that it is not so easy to setup with QTwebdriver... I tried to use QT5.7 : C:\Qt\Examples\Qt-5.7\designer\calculatorform.

kuva

I build clean example and I run it with debugger. It works OK. But if I tried to modify calculatorform application with QTwebdriver settings, I can't compile it... I tried to make modifications:

Option 1: WebDriver attaches to the running application Pros: Easy to setup The application lifecycle is not impacted. It starts as it should, not on request of WebDriver Cons: Need to modify the application code in order to run WebDriver. But a such additional code can be flagged for test build only.

Instructions: Add the QtWebDriver headers and libraries in the application build environment Question 1: Could I find somewhere Windows QT example application project with these files and all configuration changes? I would like to know that my setup is OK.... and I could compare my project against working project with QTwebdriver In the application code, include the headers: Headers.h Question 2: I added Headers.h file, but it will be needed to add a lot of other headers files to Windows QT application, am I right? Call the wd_setup(argc, argv) function with the parameters you want (See full argument list: Command Line Switches) In your application's build system set appropriate #defines for features required from QtWebDriver (e.g. to add support for QWebView define WD_ENABLE_WEB_VIEW=1, to disable sampling define QT_NO_SAMPLES with any value). This is necessary because these values are used in Headers.h which is compiled into your application. Rebuild an run your application, this will start QtWebDriver Question 3: My project does't find all files.... and a lot of undefined references errors... I tried to integrate QTwebdriver to example project: C:\Qt\Examples\Qt-5.7\designer\calculatorform. Should I do any other changes to my QT project? Connect your Selenium session to the QtWebDriver server running inside your application, e.g. in Java:

WebDriver driver = new RemoteWebDriver(new URL("http://192.168.24.1:9517"), capabilities);
System.out.println("Native page source:\n" + driver.getPageSource());
WebElement elt = driver.findElement(By.xpath("//QTextEdit"));

Note that we connect to it as a generic "remote" web driver rather than any particular browser.
hekra01 commented 7 years ago

Question 1 Example option 1: https://github.com/cisco-open-source/qtbase/pull/1 Expale option 2: https://github.com/cisco-open-source/qtwebdriver/pull/27

Check these examples, then let me know

Question 2 I added Headers.h file, but it will be needed to add a lot of other headers files to Windows QT application, am I right?

Not necessatry. Headers.h brings all the headers need by WD

ReijoSep commented 7 years ago

If you check Headers.h: There are

include "base/at_exit.h"

include "webdriver_server.h"

include "webdriver_view_transitions.h"

include "versioninfo.h"

include "webdriver_route_table.h"

include "commands/shutdown_command.h"

include "webdriver_route_patterns.h"

I haven't these headers in example of QT5.7. If I tried to compile project : C:\Qt\Examples\Qt-5.7\designer\calculatorform . My QT Creator QT application project doesn't find headers base/at_exit.h and so on... I know that you have these files in QTwebdriver source.

Have you any example of Windows QT applicaton project with integrated QTwebdriver configuration ? Have you tried to compile it? If you send example QT project to me. I could open it with my QT Creator and I could try compile it.

hekra01 commented 7 years ago

Have you any example of Windows QT applicaton project with integrated QTwebdriver configuration ? Have you tried to compile it? If you send example QT project to me. I could open it with my QT Creator and I could try compile it.

To all these questions, yes. Compiles and run. https://github.com/cisco-open-source/qtbase/pull/1/files This example modifies qtbase/examples/widgets/mainwindows/mainwindow/main.cpp to add WD

If you do option 1 the WD libs an header are available. Just modify your .pro to link with them . Sources and .pro example are in the PR in the link above

ReijoSep commented 7 years ago

I sent private email with my QT example source code to you (hekra01) Could you double-check these files, please? I don't find reason, what does it go wrong?

hekra01 commented 7 years ago

I'll look into it In the meantime you can try on your side.

You can try on Linux directly with the example i provided previously, doing the same on win is just a matter of tools.

ReijoSep commented 7 years ago

I used: Microsoft Visual Studio Community 2017 Version 15.2 (26430.12) Release VisualStudio.15.Release/15.2.0+26430.12 Microsoft .NET Framework Version 4.6.01055

I tried to build WD: I got error: unresolved external symbol....

kuva

hekra01 commented 7 years ago

msvc 2017 not supported by Qt 5.7 You should use mvsc compliant with the versions listed under c:\Qt\5.7\msvcXXX I managed t build with msvc 2015 and 2013

ReijoSep commented 7 years ago

Now I tried with MSVC 2015 32-bit (x86).

Microsoft Visual Studio Community 2015 Version 14.0.25431.01 Update 3 Microsoft .NET Framework Version 4.6.01055

Installed Version: Community

Visual Basic 2015 00322-20000-00000-AA223 Microsoft Visual Basic 2015

Visual C# 2015 00322-20000-00000-AA223 Microsoft Visual C# 2015

Visual C++ 2015 00322-20000-00000-AA223 Microsoft Visual C++ 2015

Application Insights Tools for Visual Studio Package 7.0.20622.1 Application Insights Tools for Visual Studio

I got linker error: kuva

ReijoSep commented 7 years ago

I solved it. The problem was that some projects have been used wrong target platform version. 10.0.xxx and I changed to all projects to 8.1. I double-checked C/C++ Additional Include Directories to point C:\Qt\5.7\msvc2015\include .

Next I can start to integrated QTWebDriver libraries to QT application project.

ReijoSep commented 7 years ago

I tried to add WD libraries to my QT calculator project.

I installed qt-opensource-windows-x86-msvc2015-5.7.0 from https://download.qt.io/official_releases/qt/5.7/5.7.0/

QT Creator + WD driver libraries ( QT 5.7 MSVC2015 32bit ): Now I got lot of LNK2019 errors: I don’t know, how I will find solution for this problem. I’m not so familiar with QT Creator.

main.obj:-1: error: LNK2019: unresolved external symbol "public: void thiscall CommandLine::ParseFromString(class std::basic_string<wchar_t,struct std::char_traits,class std::allocator > const &)" (?ParseFromString@CommandLine@@QAEXABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) referenced in function "int cdecl wd_setup(int,char const)" (?wd_setup@@YAHHQAPAD@Z)

Jiloc commented 7 years ago

same error here. Seems like a compatibility issue with qt because of the /Zc:wchar_t- configuration. I avoided that problem that problem commenting the line

cmd_line.ParseFromString(::GetCommandLineW());

in Headers.h.

Instead I set the options i need directly using

cmd_line.AppendArg(argument);

Anyway a fix would be good.

By the way I am using Qt5.9.1.

hekra01 commented 7 years ago

Done: https://github.com/cisco-open-source/qtwebdriver/commit/6aa0f01eb3fb25861b4d35e02f5d865b3ebf2351

Jiloc commented 7 years ago

thank you. It works on 5.9.1