Retrieving values ​​from text fields using UIAutomation

I'm trying to understand how UIAutomation can be used to run automated application tests, so I created a temperature conversion application that can be run from the JavaScript interface. Here's the user interface:

enter image description here

There is an Accessibility label for “Celsius” in the upper text box, similarly, the lower field has “Fahrenheit” as the Accessibility label. I am trying to drive through this script:

UIALogger.logStart("Test -40ºC == -40ºF");
var window = UIATarget.localTarget().frontMostApp().mainWindow();
var celsiusField = window.textFields()["Celsius"];
var fahrenheitField = window.textFields()["Fahrenheit"];
var convertButton = window.buttons()["Convert"];

celsiusField.setValue("-40");
convertButton.tap();
var fahrenheitValue = fahrenheitField.value();
if (fahrenheitValue == "-40.0") {
    UIALogger.logPass("-40C == -40F");
} else {
    UIALogger.logFail("-40C == " + fahrenheitValue + "F");
}

Celsius "-40", "" "-40,0". fahrenheitValue "Fahrenheit" (/ ), . , , , .

?

+5
3

"Fahrenheit", , ?

, value() . , , , , , ? , setValue, , UITextField?

+5

, .

0

Accessibility Inspector, , UIAutomation "" . , - , .

- :

UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
0

All Articles