Code
let label_interactable_matcher = grey_allOf([grey_accessibilityLabel("お知らせ"), GREYMatchers.matcherForInteractable()])
let action = GREYActions.actionForTap()
EarlGrey.selectElement(with: label_interactable_matcher).atIndex(0).perform(action)
Exception
Exception Name: NoMatchingElementException Exception Reason: Cannot find UI element. Exception with Action: { "Action Name": "Tap", "Element Matcher": "(((respondsToSelector(isAccessibilityElement) && isAccessibilityElement) && accessibilityLabel('お知らせ')) && interactable)", "Recovery Suggestion": "Check if the element exists in the UI hierarchy printed below. If it exists, adjust the matcher so that it accurately matches element." }
Exception Details: Error Trace: [ { "Description": "Interaction cannot continue because the desired element was not found.", "Error Domain": "com.google.earlgrey.ElementInteractionErrorDomain", "Error Code": "0", "File Name": "GREYElementInteraction.m", "Function Name": "-[GREYElementInteraction matchedElementsWithTimeout:error:]", "Line": "124", "TestCase Class": "MyAppTests.Myunittest", "TestCase Method": "testExample" } ]
View Hierarchy
ECKit_iOS.IconButton:0x7f86af9aea00; AX=Y; AX.label='お知らせ'; AX.frame={{351, 81}, {55, 50}}; AX.activationPoint={378.5, 106}; AX.traits='UIAccessibilityTraitButton'; AX.focused='N'; frame={{0, 0}, {55, 50}}; alpha=1> -UIButtonLabel:0x7f86aed75130; AX=Y; AX.label='お知らせ'; AX.frame={{362, 115}, {33, 10}}; AX.activationPoint={378.5, 120}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{11, 34}, {33, 10}}; alpha=1; UIE=N; text='お知らせ'>
Screenshot At Failure
Concerns
- There is a contradiction between view hierarchy & exception being printed
- If the exception is "NoMatchingElementException" why would Recovery Suggestion says "Check if the element exists in the UI hierarchy printed below. If it exists, adjust the matcher so that it accurately matches element"
- In my existing app after the installation if I add a new XCTestCase in UNIT TESTING TARGET, app show in black background(I was expecting it in white).
- For the splash screen suggestion in FAQ, the swift implementation solution seems difficult to implement(app module should be imported in testing module & rootViewController class
- Running the app by play button in unit testing target vs directly launching the app. Unexpected black background appears instead of white one.
- We can't use autogenerated code from UI Testing Target in Unit Test Target & Management of UI tests become difficult if we opt for both Xcode's UI Testing & EarlGrey
- Screenshot At Failure(Black screen) is contradicting with View Hierarchy