Why is the value of the picker wheel have “, X of Y” appended to the string value of the picker?

How can this be controlled? For example, I have 4 different options in my picker wheel (a blank “ ” option, BUDGET, MISC, and WORK ISSUE). If my current value of the picker wheel is BUDGET, and I call the adjustToPickerWheelValue() method to change it to MISC, I will get an error “UI Testing Failure – Internal error: unable to find current value ‘BUDGET, 2 of 4’ in possible values BUDGET, MISC, WORK ISSUE…”. It’s the “, 2 of 4” that is messing the value up. This is also the value of the picker wheel I see when I use the simulator’s accessibility inspector tool.

Also...

We have search fields embedded in the same component as our Segmented Control and the testing framework is unable to interact with it. If I record my actions in XCode, when I tap this search bar, it records the code app.tables.searchFields[“Search”].tap(), but this line does not execute properly. An error is raised that the framework cannot find the element. I have even tried to query the element by using app.descendantsMatchingType(.SearchField).element, but that still would not return the results I was looking for.

Replies

Please file two bug reports with us (using the Report Bugs link at the bottom of this page) to track these issues. If possible, please attach sample projects that shows the issues that you're running into. Thanks!

meet the same issue in Xcode7.

For a picker with only one wheel, we can access it via

element()
then just adjust to the specified value.


app.pickerWheels.element.adjustToPickerWheelValue("BUDGET")


You can also adjust a picker with mutiple wheels by building a predicate.

Not sure if if Derekhie sumbitted a radar yet, but I submitted rdar://22918650 with an example project and UI Test that fails.


Also, joemasilotti's proposed solution doesn't solve this problem for me.

Much appreciated - thanks!

Hmm, what about a BEGINSWITH predicate?


let budget = NSPredicate(format: "label BEGINSWITH 'BUDGET'")
let budgetPicker = app.pickerWheels.elementMatchingPredicate(budget)
budgetPicker.adjustToPickerWheelValue("MISC")


Also try using a predicate on value instead of label, by replacing line 01. with the following:


let budget = NSPredicate(format: "value BEGINSWITH 'BUDGET'")

It does not work.

Have you found any workaround?

One of a workaround for me is use


func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
}

instead of

func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView?) {
}

What is the status of this?

I am running into this situation when using XCTest as well.

Using `titleForRow` works for UIPicker wheel selection with `adjust(toPickerWheelValue` in UITest, but it is broken for my intended purpose. I need the custom views that `viewForRow` provides as part of UITest + Fastlane/Snapshot.

I am facing the same issue when using XCTest as well. Changing from "viewForRow" to "titleFoRow" broke everything else.

How is the status of this issue? I am running into the same problem

How is the status of this issue?

This bug (r. 22918650) is not yet fixed )-:

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

let serverPicker = app.pickerWheels["originalValue"]

serverTextField.tap()

serverPicker.adjust(toPickerWheelValue: "newValue")


This works for me.


maybe the .tap function is used to get the keyboard focused and then we can set the value? I'm not sure.