Failing to Set PickerWheel Value

Hi Everyone!

I’ve been having trouble with setting the value of a PickerWheel in iOS/XCUI. Even though I’m using sendKeys() and setValue(), nothing happens. I don’t know if it may be because I’m casting my driver as an IOSDriver from an originally AppiumDriver and because of that setValue() may not work correctly???..

Anyway, I read Appium’s logs and found these pretty interesting, but still don’t know what to do. I wish to select the value “Stage/Env5” and when I call sendKeys and setValue methods like this:

pickerElement.setValue("Stage/Env5");

Or like this:

pickerElement.sendKeys("Stage/Env5");

Appium’s Logs send me this:

Logs:

[2017-08-04 10:24:40][HTTP] → POST /wd/hub/session/b70cb12b-c2c7-4ad4-a263-800b1da07fcf/appium/element/998EA423-4E70-4D20-B720-7E72DCB3EEA2/value {“id”:“998EA423-4E70-4D20-B720-7E72DCB3EEA2”,“value”:“Stage/Env5”}
[2017-08-04 10:24:40][MJSONWP] Calling AppiumDriver.setValueImmediate() with args: [“Stage/Env5”,“998EA423-4E70-4D20-B720-7E72DCB3EEA2”,“b70cb12b-c2c7-4ad4-a263-800b1da07fcf”]
[2017-08-04 10:24:40][XCUITest] Executing command ‘setValueImmediate’
[2017-08-04 10:24:40][XCUITest] There is currently no way to bypass typing using XCUITest. Setting value through keyboard
[2017-08-04 10:24:40][JSONWP Proxy] Proxying [POST /element/998EA423-4E70-4D20-B720-7E72DCB3EEA2/value] to [POST http://localhost:8100/session/47097191-8B6C-4443-BBC7-166F2CC8D1AA/element/998EA423-4E70-4D20-B720-7E72DCB3EEA2/value] with body: {“value”:[“S”,“t”,“a”,“g”,“e”,“/”,“E”,“n”,“v”,“5”]}
[2017-08-04 10:24:41][iOSLog] [IOS_SYSLOG_ROW] Aug 4 10:24:39 AMAC02NX7BDG085 testmanagerd[2139]: *** LOG MESSAGE QUOTA EXCEEDED - SOME MESSAGES FROM THIS PROCESS HAVE BEEN DISCARDED ***
[2017-08-04 10:24:42][iOSLog] [IOS_SYSLOG_ROW] Aug 4 10:24:40 AMAC02NX7BDG085 XCTRunner[2143]: Enqueue Failure: Internal error: unable to find current value ‘default, 3 of 6’ in possible values Latest/Env5, Latest/Env2, default, UAT1 (Finder only), Stage/Env2, Stage/Env5 for the picker wheel “default, 3 of 6” PickerWheel /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgentRunner/UITestingUITests.m 35 1
[2017-08-04 10:24:42][iOSLog] [IOS_SYSLOG_ROW] Aug 4 10:24:40 AMAC02NX7BDG085 XCTRunner[2143]: Enqueue Failure: Failed to receive event delivery confirmation within 0.0s of the original dispatch. /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgentRunner/UITestingUITests.m 35 1
[2017-08-04 10:24:42][JSONWP Proxy] Got response with status 200: {“value”:{},“sessionId”:“47097191-8B6C-4443-BBC7-166F2CC8D1AA”,“status”:0}
[2017-08-04 10:24:42][MJSONWP] Responding to client with driver.setValueImmediate() result: null
[2017-08-04 10:24:42][HTTP] ← POST /wd/hub/session/b70cb12b-c2c7-4ad4-a263-800b1da07fcf/appium/element/998EA423-4E70-4D20-B720-7E72DCB3EEA2/value 200 1619 ms - 76

I don’t know how to take these logs, but I’m pretty new to Appium.

Another thing that I think may be causing this is that, PickerWheel’s available values are the ones that I can read in the Logs, but when I inspect the screen, the setted value is different, its showed as this:

nameOfValue, indexOfValue of totalNumberOfValues

Instead of the value itself by its own. I also have some pictures:
image

I hope you guys can help 'cause I’ve tried everything I can, and searched through Google but haven’t found a solution in the related issues.

Thanks!

@BrunoAlva, I had a similar issue with PickerWheels and used JavaScript executor + Mobile Gestures to resolve the issue. Below if the function I am using as a workaround. Hope this will resolve your issue too

public static boolean Select_Required_Value_From_PickerWheel(String ByClassName_ToFindChildrenInPicker, String ExpectedElementToSelect, int PickerWheelIndex) {
//Initialize return variable
boolean bln_ExpectedElementToSelect = false;

	try {
		//Get PickerWheel Item
		List<MobileElement> wheels = appiumDriver.findElements(MobileBy.className("XCUIElementTypePickerWheel"));
		int WheelListSize = wheels.get(PickerWheelIndex).findElements(By.className(ByClassName_ToFindChildrenInPicker)).size();
		
		for (int i = 0; i < WheelListSize; i++) {
			
			//Read the selected value
			String strPickerWheelSelectedValue = wheels.get(PickerWheelIndex).getText();
			if (strPickerWheelSelectedValue.contains(ExpectedElementToSelect)){
				bln_ExpectedElementToSelect = true;
				break;
			}
			
			//Navigate to next item in the list
			JavascriptExecutor js = (JavascriptExecutor) appiumDriver;
			Map<String, Object> params = new HashMap<>();
			params.put("order", "next");
			params.put("offset", 0.15);
			params.put("element", ((RemoteWebElement) wheels.get(PickerWheelIndex)).getId());
			js.executeScript("mobile: selectPickerWheelValue", params);
		}
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	//Return value
	return bln_ExpectedElementToSelect;
}
1 Like

Thanks much for sharing code. struggling to resolve this issue & got solution.
Though it takes much time to get pickerwheel size & to select required option, tests are executing successfully.
not sure why .sendkey() are not working to pick values from picker wheel.