cisco-open-source / qtwebdriver

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

unable to get the web source code #44

Closed jmforum closed 7 years ago

jmforum commented 7 years ago

Dear all,

I use qtwebdriver on arm with the Option 1.

curl 10.150.67.32:9002/status
{"status":0,"value":{"build":{"revision":"aa","time":"May 22 2017 16:30:38 PST","version":"1.3.3"},"os":{"arch":"armv7l","name":"Linux","version":"4.1.13"}}}

My app works fine, it's load web page correctly. But when use selenium in C# nothings append

IWebDriver driver = new RemoteWebDriver(new Uri("http://10.150.67.32:9002"), DesiredCapabilities.Chrome());
driver.Navigate().GoToUrl("http://192.168.10.254/home");

driver.PageSource always equals to

<?xml version="1.0" encoding="UTF-8"?>
<QWidget elementId="2fe0d72f31358ba5f53920cdf34ed0be" className="QWidget"/>

console log when execute GoToUrl command

[SEVR]: cant create view able to handle url.
[WARN]: Command finished (/session/078f98dd681fdbbab0902c674a1a2f92/url) with response {
   "sessionId": "078f98dd681fdbbab0902c674a1a2f92",
   "status": 13,
   "value": {
      "message": "cant create view able to handle url."
   }
}

Do I miss something ?

Best Regards JM

jmforum commented 7 years ago

I think I found something. driver.SwitchTo().Window(driver.WindowHandles[0]) then driver.Url = "qtwidget://Browser" and

driver.PageSource =
<?xml version="1.0" encoding="UTF-8"?>
<Browser elementId="797c83c693460fa990dbf0f97eb8dfad" className="Browser">
    <QRubberBand id="qt_rubberband" elementId="dae106d13f4f42f03def754242ce597d" className="QRubberBand"/>
    <QWidget id="centralWidget" elementId="5d62014b47008362fb29ac8a78e4f068" className="QWidget">
        <QWidget id="vLayoutWidget" elementId="422819082c1d3ef1f6460e43ab7b9243" className="QWidget">
            <QWidget id="hLayoutWidget" elementId="f65d086b1000ecdc65cac5a9caa58b1e" className="QWidget">
                <QWebView id="webView" elementId="10868eaf1676e668296445ee1ff197ff" className="QWebView"/>
            </QWidget>
        </QWidget>
    </QWidget>
</Browser>

but could not have the html source code of displayed web page

jmforum commented 7 years ago

I think I found something. after driver.SwitchTo().Window(driver.WindowHandles[0]) then driver.Url = "qtwidget://Browser" and

driver.PageSource = 
<?xml version="1.0" encoding="UTF-8"?>
<Browser elementId="0e6f52520ad325eb933c15d79543b3a1" className="Browser">
    <QRubberBand id="qt_rubberband" elementId="3e182a7ea459541882ccbf34b46fcf1a" className="QRubberBand"/>
    <QWidget id="centralWidget" elementId="7171f0cee2d4426c45014b796b155336" className="QWidget">
        <QWidget id="vLayoutWidget" elementId="3b2b4f59609ea5d431a04e15d067cc50" className="QWidget">
            <QWidget id="hLayoutWidget" elementId="ed80345b58ea149c4da5daf6d21154e3" className="QWidget">
                <QWebView id="webView" elementId="9477c10ce497532333a09de1fea458ea" className="QWebView"/>
            </QWidget>
        </QWidget>
    </QWidget>
</Browser>

but I couldn't have the html source page of web page current displayed.

Best regards

hekra01 commented 7 years ago

Long explanation: https://github.com/cisco-open-source/qtwebdriver/wiki/Hybridity-And-View-Management#hybrid-uis

Short : there are several windows; you need to select the correct one (not always [0]) to get the html. Check the code sample in the previous link

console log when execute GoToUrl command

This is normal. You need to select the correct view to open you url. select webview to open http, selectt widget view to open qtwidget, etc...

jmforum commented 7 years ago

Hi hekra01, Thanks a lot for your reply.

I saw this link in my second post. I have only 2 WindowHandle (one with url equals to qtwidget://QWidget and other equals to qtwidget://Browser) inside the first one PageSource equals

<?xml version="1.0" encoding="UTF-8"?>
<QWidget elementId="bc5d574374c1c73ad66778c8043ef875" className="QWidget"/>

But I don't understand who to select <QWebView id="webView" elementId="9477c10ce497532333a09de1fea458ea" className="QWebView"/>

JM

hekra01 commented 7 years ago

From the code you posted

driver.PageSource = 
<?xml version="1.0" encoding="UTF-8"?>
<Browser elementId="0e6f52520ad325eb933c15d79543b3a1" className="Browser">
    <QRubberBand id="qt_rubberband" elementId="3e182a7ea459541882ccbf34b46fcf1a" className="QRubberBand"/>
    <QWidget id="centralWidget" elementId="7171f0cee2d4426c45014b796b155336" className="QWidget">
        <QWidget id="vLayoutWidget" elementId="3b2b4f59609ea5d431a04e15d067cc50" className="QWidget">
            <QWidget id="hLayoutWidget" elementId="ed80345b58ea149c4da5daf6d21154e3" className="QWidget">
                <QWebView id="webView" elementId="9477c10ce497532333a09de1fea458ea" className="QWebView"/>
            </QWidget>
        </QWidget>
    </QWidget>
</Browser>

You have 2 windowss:

To select the web view

Exmple of this is private String selectWindow(String protocol) { in the code sample at https://github.com/cisco-open-source/qtwebdriver/wiki/Hybridity-And-View-Management#hybrid-uis

jmforum commented 7 years ago

I agree with you but I have only 2 WindowHandles WindowHandles[0].Url = "qtwidget://QWidget" WindowHandles[1].Url = "qtwidget://Browser" But nothing starting with http

hekra01 commented 7 years ago

Can you paste you wd.gypi?

jmforum commented 7 years ago
{
  'variables': {
    'QT5': '1',
    'WD_CONFIG_QWIDGET_BASE': '0',
# If Qt >= 5.6 set 'WD_CONFIG_WEBKIT' : '0'
    'WD_CONFIG_WEBKIT': '1',
    'WD_CONFIG_QUICK': '0',
    'WD_CONFIG_PLAYER': '0',
    'WD_CONFIG_ONE_KEYRELEASE': '0',
    'QT_INC_PATH': '/home/user/workspace/advantage_Integration/buildroot/outputPod/host/usr/arm-buildroot-linux-gnueabihf/sysroot/usr/include/qt5',
    'QT_BIN_PATH': '/home/user/workspace/advantage_Integration/buildroot/outputPod/host/usr/bin/',
    'QT_LIB_PATH': '/home/user/workspace/advantage_Integration/buildroot/outputPod/host/usr/arm-buildroot-linux-gnueabihf/sysroot/usr/lib'
  },
}
hekra01 commented 7 years ago

hm, WD_CONFIG_QWIDGET_BASE should be 1, since you are using qtwidgets

jmforum commented 7 years ago

It's works Thanks a lot