Mobile: selectPickerWheelValue

How can I use the appium method to automate the picker wheeler element using javascript?

my code snippet:

const elemId = await $(`//XCUIElementTypePickerWheel[@value=\"${value}\" and @type="XCUIElementTypePickerWheel"]}`)
driver.execute('mobile: selectPickerWheelValue',
        'order': 'next',
        'offset': 0.15,
        'element': elemId

does not work
it throw the error
0-9] script: ‘mobile: selectPickerWheelValue’,

[0-9] args: [ { order: ‘next’, offset: 0.15, element: [Element] } ]

[0-9] }

[0-9] 2024-01-29T01:44:40.739Z WARN webdriver: Request failed with status 400 due to elementId is expected to be set for selectPickerWheelValue method

[0-9] 2024-01-29T01:44:40.739Z INFO webdriver: Retrying 30/30

[0-9] 2024-01-29T01:44:40.740Z INFO webdriver: [POST]


this is NOT element ID.

// Java
String elemId = ((RemoteWebElement) element).getId();

for JavaScript you need to know better…

got it work for JS
const elemId = await $(${SELECTORS.PICKER_IOS});
driver.execute(‘mobile: selectPickerWheelValue’,
‘order’: ‘next’,
‘offset’: 0.15,
‘element’: elemId

PICKER_IOS: “//XCUIElementTypePickerWheel”,

however, how can I pass in the value or item in the picker wheeler

for example my select picker has items such as ‘es’, ‘en’, ‘vi’, etc

how to pass it in?

i try const elemId = await $(${SELECTORS.PICKER_IOS}).get(3);
but it said
error: Can’t call “get” on element with selector “//XCUIElementTypePickerWheel”, it is not a function

With iOS it may not work when wheels have some complex values e.g. country image + country phone extension.
But when wheels are simple numbers if often works very fast.

// Java