Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIPickerView does not contain desired value #1051

Closed
petrmrakava opened this issue Nov 23, 2018 · 19 comments · Fixed by #1497
Closed

UIPickerView does not contain desired value #1051

petrmrakava opened this issue Nov 23, 2018 · 19 comments · Fixed by #1497

Comments

@petrmrakava
Copy link

Sorry guys, but all about iOS Picker was closed without any conclusion. I have exactly the same issue as #798. Also, the question on stackoverflow has no answer https://stackoverflow.com/questions/50082463/testing-picker-with-detox-in-react-native

so

if I use "testID":
await element(by.id('testIdPicker')).setColumnToValue(0, 'en');
I get
"Description" : "Interaction cannot continue because the desired element was not found."
If I use "type":
await element(by.type('UIPickerView')).setColumnToValue(0, 'en');
I get
"Description" : "UIPickerView does not contain desired value!"

Detox, Node, Device, Xcode and macOS Versions

  • Detox: 9.0.4
  • React Native: 0.57.4
  • Node: 11.1.0
  • Device:*
  • Xcode: 10.0
  • macOS: 10.13.6

detox

@LeoNatan
Copy link
Contributor

Can you please create a demo project that reproduces this?

@petrmrakava
Copy link
Author

Sorry I can not share our project with you, but I created an example based on #798. There are the same issues as I reported.
You can find it here: https://github.com/petrmrakava/Detox/tree/petrmrakava/iosPicker

@LeoNatan
Copy link
Contributor

Great, thank you!

@fedeerbes
Copy link

Hi @LeoNatan, any progress in this? i'm facing the same issue.

@LeoNatan
Copy link
Contributor

Sorry, I am busy with other projects at the moment.

@LeoNatan
Copy link
Contributor

LeoNatan commented Dec 6, 2018

See this:
facebook/react-native#22537

@LeoNatan
Copy link
Contributor

LeoNatan commented Dec 6, 2018

It seems like an RN bug.

@fedeerbes
Copy link

thanks @LeoNatan i'll be waiting for the next version with that fix.

@LeoNatan
Copy link
Contributor

LeoNatan commented Jun 30, 2019

@fedeerbes Can you please test to see if the issue still reproduces with modern version of RN? Thanks

@revh
Copy link

revh commented Jul 2, 2019

Hi, first of all thanks for the great work.

It seems that the issue still reproduces also with RN 0.59.9

await element(by.type("UIPickerView")).setColumnToValue(0, "value");

results in

"Description" : "UIPickerView does not contain desired value!"

@noomorph
Copy link
Collaborator

noomorph commented Jul 2, 2019

Just to make sure, I wonder how this test passes then?

it('datePicker should trigger change handler correctly', async () => {
await element(by.type('UIPickerView')).setColumnToValue(1, "6");
await element(by.type('UIPickerView')).setColumnToValue(2, "34");
await expect(element(by.id('localTimeLabel'))).toHaveText('Time: 06:34');
});

@revh
Copy link

revh commented Jul 2, 2019

I can see that you are using DatePickerIOS Component for the test, but I got the issue with Picker or PickerIOS Components.

@LeoNatan
Copy link
Contributor

LeoNatan commented Jul 2, 2019

DatePickerIOS is mapped to a UIDatePicker, which is a wrapper around UIPickerView. The same API should work with both.

@revh
Copy link

revh commented Jul 2, 2019

Thanks for your reply, I see your point.

I tried to add into my project the same test as the one that @noomorph quoted and the same DatePickerIOS component and everything worked as expected.
So this let me wonder if there are any subtle differences between those two Picker and DatePickerIOS implementations.

@LeoNatan
Copy link
Contributor

LeoNatan commented Jul 2, 2019

Hmm, I think I see the problem. Earl Grey expect the picker view to implement a data source, but the clowns in RN just implement the methods and rely on undocumented behavior of iOS. Investigating.

@LeoNatan
Copy link
Contributor

LeoNatan commented Jul 2, 2019

I'll be providing a fix soon. As a bonus, I will also simplify setting picker values in RN date pickers (allow selecting by id, not just by class).

LeoNatan added a commit that referenced this issue Jul 2, 2019
Closes #1051
Also updated docs
LeoNatan added a commit that referenced this issue Jul 2, 2019
* Fix several picker woes

Closes #1051
Also updated docs

* Remove requirement for matcher.js
@fedeerbes
Copy link

Hi @LeoNatan, thanks for the work you did it here. Reading the above, I'll try with the new version and let you know how it goes.

@LeoNatan
Copy link
Contributor

LeoNatan commented Jul 2, 2019

Thanks!

@revh
Copy link

revh commented Jul 2, 2019

I tested the new implementation and it seems to be working properly now.
Thanks @LeoNatan 🥇 👍

@lock lock bot locked as resolved and limited conversation to collaborators Jul 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants