I’m trying to write the simplest UI tests for an Android application(qt) with a QML interface.
In QML components, I set properties via the Accessible object. (qml code at the end)
The Appium test is implemented according to the instructions:
- appium server, UiAutomator2 driver, requirements
- write a test (js)
I have configured the startup parameters so that the application under test runs on AVD (android virtual device)
When I run the test, the application under test runs successfully on AVD, the interface is displayed.
What works fine in the test:
-
getting elements using locators
const passwordInput = await driver.$(‘~PasswordInput’);
-
getting information about the coordinates of an element
await passwordInput.getLocation()
await passwordInput.getSize()
-
clicking on an element.
await applyButton.click()
But none of the methods for getting text data from an element works:
await passwordInput.getText() // EMPTY RESULT
await passwordInput.getAttribute('text') // EMPTY RESULT
await passwordInput.getProperty('text') // ERROR
await passwordInput.getValue() // ERROR
Is it possible to read the text of the QML component from the appium test?
=====================================================
Capability Set:
{
"platformName" : "Android",
"appium:platformVersion": "14",
"appium:deviceName" : "emulator-XXXX",
"appium:app" : "C:/temp/androidtestapp.apk",
"appium:automationName" : "UiAutomator2"
}
part of main.qml:
TextField {
id : idPasswordInput
focus : true
Layout.fillWidth : true
objectName : "PasswordInputName"
text : "enter password..."
Accessible.role : Accessible.EditableText
Accessible.name : "PasswordInput"
Accessible.description : "PasswordInput description"
Accessible.focusable : true
Accessible.ignored : false
Keys.onPressed: (event)=> {
console.log("PasswordInput key:", event.key, "/", event.text);
}
}
Running the test
node C:temptest.js
used:
- Qt 6.7.2
- appium, UiAutomator2, webdriverio – latest versions