Automating a Picker Wheel using Testsigma
Tags: pickerwheel, iosxcuitest, automatingpickerwheel, softwaretesting
Published: 2020-01-09 10:10:44

---
title: Automating a Picker Wheel using Testsigma
published: true
description: 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.
tags: pickerwheel, ios xcuitest, automating pickerwheel,software testing
canonical_url: https://testsigma.com/blog/automating-a-pickerwheel-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 using the scriptless testing tool,<a href="https://testsigma.com"> Testsigma</a>.

<strong>How to automate PickerWheel UI element using Appium:</strong>
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:

<strong>Approach 1:</strong> 
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:

<strong>driver.findElement(By.xpath(“//XCUIElementTypePickerWheel[@value=’Today’]”)).sendKeys(“Wed 25 Dec”);</strong>

Here:

<strong>Element located by pickerWheel is “//XCUIElementTypePickerWheel[@value=’Today’]”.</strong>

<strong>Value picked by pickerWheel is “Wed 25 Dec”.</strong>

Refer image below to get more clarity about PickerWheel via Appium Inspector:


<strong>Approach 2:</strong> 
In the second approach, javascript’s mobile method selectPickerWheelValue can be used:

<strong>{</strong>

<strong>HashMap<String, Object> params = new HashMap<>();</strong>

<strong>params.put(“order”, “next”);</strong>

<strong>params.put(“offset”, 0.15);</strong>

<strong>params.put(“element”, ((RemoteWebElement) pickerWheelElement).getId());</strong>

<strong>driver.executeScript(“mobile: selectPickerWheelValue”, params);</strong>

<strong>}</strong>

And it accesses the pickerWheel values in forward or backward direction, as needed, using the above parameters.   

<strong>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.</strong>

<strong>Offset: The height of the wheel at which click should be done.</strong>

<strong>Element: PickerWheel element.</strong>

Let’s discuss how the pickerWheel interaction can be automated in an iOS native application using simple natural language in <strong>Testsigma</strong>:

  <strong>“ Pick option by text test data in the UI identifier picker view”</strong>


Here, 

<strong>test data:</strong> The pickerWheel value that should be selected regardless of direction.
<strong>ui identifier:</strong>  locator of the PickerWheel Element.