Skip to content

Enable searching QML elemnts by objectName from JavaScript #6

Closed
@hekra01

Description

@hekra01

wd.executeScript(string) can be used to find qml elements by object name
8498ab2

e.g:
with such qml

Rectangle {
    id: button
    objectName: "button"
    Text {
        id: buttonText
        objectName: "buttonText"
        text: parent.description
        font.pixelSize: parent.height * .5
    }
}

then such selenium test works

class SeleniumTest(unittest.TestCase):
    def testPage(self):
        self.browser.get("file:///home/hekra/qtwebdriver/b.qml")
        v = self.browser.execute_script("var v = ObjectNameUtils.findChild('button'); return v.objectName;")
        print "js result ", v
        v = self.browser.execute_script("var v = ObjectNameUtils.findChild('buttonText'); return v.font.pixelSize;")
        print "js result ", v
        v = self.browser.execute_script("var v = ObjectNameUtils.findChild('buttonText'); return v.parent.objectName;")
        print "js result ", v

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions