google / google/EarlGrey

GREYElementMatcherBlock is not working in Earlgrey2

Open
#1,634 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Objective-C
Stars
5.7k
Forks
737
Avg merge
1d 20h
Merged PRs (30d)
5

Description

Found an issue while migrating to Earlgrey 2.. We've been using `GREYElementMatcherBlock` to fetch children under a parent of specific type.. ex: cells under a table view... With Earlgrey 2, when the matcher block is called with `EDOObject`, the call is getting stuck...

Here's the sample code

```
func queryForChildren(type: AnyClass, parent: String) -> [String] {
var elements:[String] = []

let matcher = grey_allOf([
grey_kindOfClass(type),
grey_ancestor(grey_allOf([grey_accessibilityID(parent)]))
])

let queryMatcher = GREYElementMatcherBlock.matcher(matchesBlock: {
obj -> Bool in
guard matcher.matches(obj) else {
return false
}

let view = obj as AnyObject
elements.append( view.accessibilityLabel)
return true
}, descriptionBlock: { (description) in
description.appendText("Element Query Matcher")
})

var error: NSError? = nil
EarlGrey.selectElement(with: queryMatcher)
.assert(grey_notNil(), error: &error)

return elements
}
```

Earlgrey thread goes to a wait/frozen state at `matcher.matches(obj)` call and never returns back.

Contributor guide

Open the contributing guide

Research direction

Start with the provided queryForChildren example and reproduce the wait at matcher.matches(obj) during an EarlGrey 2 query. Trace how GREYElementMatcherBlock receives EDOObject and determine why the call does not return; done means the matcher completes and the element query returns normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
objective-c, swift
Domain
mobile, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.