cisco-open-source / qtwebdriver

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

How to get QML Window properties #54

Open Jiloc opened 7 years ago

Jiloc commented 7 years ago

When the Window(and/or ApplicationWindow) component is instantiated it is replaced by a RootItem.

You can check this by calling selenium's webdriver.page_source (in Python).

At the same time all properties I defined in the component seem to disappear.

A Little example:

import QtQuick 2.8
import QtQuick.Window 2.2

Window {
    visible: true
    width: 640
    height: 480
    property alias innerText: textEdit.text
    property string testString: "test"

    TextEdit {
        id: textEdit
        text: qsTr("Enter some text...")
        verticalAlignment: Text.AlignVCenter
        anchors.top: parent.top
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.topMargin: 20
        Rectangle {
            anchors.fill: parent
            anchors.margins: -10
            color: "transparent"
            border.width: 1
        }
    }
}

If i call webdriver.page_source I get

<?xml version="1.0" encoding="UTF-8"?>
<RootItem elementId="86a3c2d01650fca2c9dc2363884ebfd2">
    <TextEdit elementId="223ee63e06bccf63aede46e315c86ac2">
        <Rectangle elementId="fe6f1d7dfd8608cf1bd9b6c167e73416"/>
    </TextEdit>
</RootItem>

If i try to get innerTextor testStringproperties with webdriver.find_element_by_tag_name("RootItem").get_attribute("testString") it returns Noneand the server logs a warning:

[13145972118.403][WARNING]: property not found.

Jiloc commented 7 years ago

Was it unclear or you don't know how to solve it? If it's the former I'd be happy to clarify what I meant!