Last updated: Mar 15, 2018 16:56
Automating a PickerWheel UI element testing is now very easy when running an Appium script over the XCUITest infrastructure.
Apple PickerWheel view APIs
Apple applies two main APIs for implementing the PickerWheel in an application UI, these APIs refer to the types of the sub elements organized in the PickerWheel rows.
The APIs types are defined by the developer that developed the application:
- Title for row : when the pickerwheel values are of type "String" , arranged in rows.
- View for row : when the pickerwheel values are of type "View" , arranged in rows. This view type enables the developer to design each row with a more complex UI, for example with images.
These API types are not visible when inspecting the application with the object spy widget, for Strings value we recommend to use the Automation API that is suitable to "title for row" API. In case it does not work, try to use the API that is suitable to "view for row".
Automation API (Via Appium XCUITest)
Automating "title for row" PickerWheel view type - Use the "sendKeys" command:
Automating "view for row" PickerWheel view type - Use the "executeScript" command:
- element: PickerWheel's internal element id (as hexadecimal hash string) to select. The element must be of type XCUIElementTypePickerWheel. Mandatory parameter
- order: Either next to select the value next to the current one from the target picker wheel or previous to select the previous one. Mandatory parameter
- offset: The value in range [0.01, 0.5]. It defines how far from picker wheel's center to perform the click. The actual distance is calculated by multiplying this value by the actual picker wheel height. Too small an offset value may not change the picker wheel value and too high a value may cause the wheel to switch two or more values at once. Usually the optimal value is located in range [0.15, 0.3]. 0.15 by default
[Reference: Appium pickerWheel automation API]