Automating a Picker Wheel using Testsigma
Pickerwheel is the UI element, specific to mobile devices that allows a user to pick a single value from multiple values displayed as a scrollable list. This UI element is available on both Android and iOS.
Here, in this article, we will be discussing the automation of Picker Wheel specifically for iOS.
How to automate PickerWheel UI element using Appium:
Automation of an iOS-specific pickerWheel UI element via Appium using the XCUITest driver is quite simple. Let’s look at 2 approaches to do so below:
The simplest way to automate the PickerWheel is via the “driver.sendKeys()” method. PickerWheel contains values in the form of strings. The same string that needs to be selected can be passed as a value via sendKeys and the needed result can be achieved.
Here, the pickerWheel element is accessed via method “XCUIElementTypePickerWheel” as in the sample code below:
driver.findElement(By.xpath(“//XCUIElementTypePickerWheel[@value=’Today’]”)).sendKeys(“Wed 25 Dec”);
Element located by pickerWheel is “//XCUIElementTypePickerWheel[@value=’Today’]”.
Value picked by pickerWheel is “Wed 25 Dec”.
Refer image below to get more clarity about PickerWheel via Appium Inspector:
HashMap<String, Object> params = new HashMap<>();
params.put(“element”, ((RemoteWebElement) pickerWheelElement).getId());
driver.executeScript(“mobile: selectPickerWheelValue”, params);
And it accesses the pickerWheel values in forward or backward direction, as needed, using the above parameters.
- Order: The value of order determines where to pick the next value – for forward direction “next” value should be passed and for backward “previous” should be passed.
- Offset: The height of the wheel at which click should be done.
- Element: PickerWheel element.
Let’s discuss how the pickerWheel interaction can be automated in an iOS native application using simple natural language in Testsigma:
“ Pick option by text test data in the UI identifier picker view”
test data: The pickerWheel value that should be selected regardless of direction.
ui identifier: locator of the PickerWheel Element.