-
Notifications
You must be signed in to change notification settings - Fork 741
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unneeded GREYKeyboard method. Add Examples and more samples, t…
…ests and any comment/ test changes
- Loading branch information
Showing
8 changed files
with
87 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,4 +75,5 @@ | |
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# EarlGrey Usage Examples | ||
# Add any example of custom matchers, asserts etc. that you have found very | ||
# useful in your EarlGrey tests. | ||
|
||
**Selecting the first match via a custom Swift matcher** | ||
|
||
When an application has exact duplicate elements (every attribute is the same, | ||
including their hierarchy), then the correct fix is to update the app to avoid | ||
duplicating the UI. When that's not possible, a workaround is to match on | ||
the first element. | ||
|
||
```swift | ||
// Swift Custom Matcher | ||
/** | ||
* Example Usage: | ||
* | ||
* EarlGrey().selectElementWithMatcher(grey_allOfMatchers( | ||
* grey_accessibilityID("some_id"), | ||
* grey_interactable(), | ||
* grey_firstElement())).assertWithMatcher(grey_notNil()) | ||
* | ||
* Only intended to be used with selectElementWithMatcher. Don't | ||
* use grey_firstElement in assertWithMatcher as it won't do anything. | ||
*/ | ||
func grey_firstElement() -> GREYMatcher { | ||
var firstMatch = true | ||
let matches: MatchesBlock = { (element: AnyObject!) -> Bool in | ||
if firstMatch { | ||
firstMatch = false | ||
return true | ||
} | ||
|
||
return false | ||
} | ||
|
||
let description: DescribeToBlock = { (description: GREYDescription!) -> Void in | ||
guard let description = description else { | ||
return | ||
} | ||
description.appendText("first match") | ||
} | ||
|
||
return GREYElementMatcherBlock.init(matchesBlock: matches, descriptionBlock: description) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.