-
Notifications
You must be signed in to change notification settings - Fork 148
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
Matching in RecyclerView not working with different ViewTypes #547
Comments
Hi, @cee-dee! firstChild method returns literally the first child in the list. The child type you provide to this method serves only for casting item to exact type you expect. It's not used as a matcher. Method isFirst is a check that serves as an assertion. Again, it's not used as a matcher. I suggest you to use childWith method. It would look someting like this: onScreen<AutoCompleterScreen> {
resultList {
childWith<AutoCompleterScreen.AutoCompleterResult> { withDescendant { withId(R.id.destination_title) } } perform {
// your check here
}
}
} Please, check kakao samples if you need more info |
Thank you for the suggestion! I've tried this and it gives me
Actually, I need to match the first of these views on tap on it, like I implemented the Espresso matcher doing that. That was the reason why I tried also using |
I found the solution. So, it's possible using Kaspresso/Kakao ootb without usingEspresso code. Actually, the code
had two flaws: a) b) In my scenario, the RecyclerView was pre-populated with data from a previous search, meaning that already items matching the above criteria were in the RecyclerView, but clicking on them wasn't intended until the RecyclerView is updated with the currently running search (which is issued earlier in the test). Thus I needed to add a check that ensures the search results are for the current keyword. This is the working code:
|
@cee-dee do you know, that your and this check: recyclerView {
childWith<ChatMainScreen.ChatRecyclerItem> {
containsText("Добро пожаловать в наш чат")
isFirst()
}
} And test is passed! But it's not the first, it's index is "3" in the list! Also we can check it, for example, for visibility, and it will be visible and invisible in the same time :) |
No, it doesn't work wrong. That is exactly the behaviour I intended: first item in the Recycler view that contains the text. |
For my tests it's not true. I described it above |
If you need to check for something different, then write other matching for that. Obviously if you have differing requirements you then cannot use my matching.
Am 27. Sept. 2023, 11:46, um 11:46, Pirokar ***@***.***> schrieb:
…For my tests it's not true. I described it above
--
Reply to this email directly or view it on GitHub:
#547 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
I'm having issues operating a RecyclerView with different ViewTypes in my UI tests, although I'm using the latest Kaspresso 1.5.2:
The RecyclerView is used for an Auto Completer and has two ViewTypes:
What I want to achieve: click on the first item in the RecyclerView which has a View matching my "regular" items. Caveat: the first item in the RecyclerView does not have this type but the above mentioned "special item" type.
The view xmls look like:
and
I've got a screen object for the RecyclerView:
I tried different approaches in my test, I was hoping that this will work:
But it wasn't.
I kept on experimenting and this one worked once, but I couldn't repeat it, so it might be related to the app not being freshly installed:
On the other hand, I managed to come up with some Espresso code that actually works -- but as I'm using Kaspresso, I'd like to learn how to leverage that framework:
using
Maybe, Kakao/Kaspresso has problems with the looping of the MainThread, but it should support going without that because of its internal flakysafe implementations.
The text was updated successfully, but these errors were encountered: