qtwebdriver icon indicating copy to clipboard operation
qtwebdriver copied to clipboard

How to get QML Window properties

Open Jiloc opened this issue 8 years ago • 1 comments

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 innerText or testString properties with webdriver.find_element_by_tag_name("RootItem").get_attribute("testString") it returns None and the server logs a warning:

[13145972118.403][WARNING]: property not found.

Jiloc avatar Jul 31 '17 15:07 Jiloc

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!

Jiloc avatar Aug 30 '17 13:08 Jiloc