Closed
Description
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