Keyboard 'Done' button is disabled but EarlGrey reports otherwise (and was able to click on it)
- Dominant language
- Objective-C
- Stars
- 5.7k
- Forks
- 737
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 5
Description
Hi,
Thanks for the great tool!
I'm trying to implement logic to check whether the soft keyboard's 'Done' button is enabled under certain circumstances (e.g. no input in UITextField). I use the following check:
```
let shouldEnable : Bool // true or false
let assertMatcher = shouldEnable ? grey_enabled() : grey_not(grey_enabled())
EarlGrey.select(elementWithMatcher: grey_accessibilityID("Done")).assert(with: assertMatcher)
```
The error is provided at the bottom, which should confirm that only 1 element is found, and it appears that it is indeed the keyboard's Done button. XCode's accessibility inspector reports that the enabled property of the button is 'false'.
Alternatively, I tried to do the following:
EarlGrey.select(elementWithMatcher: grey_accessibilityID("Done")).perform(grey_tap())
... and the test passes. I could see in the UI that the 'Done' button appeared to get pressed (appears selected), despite it being disabled/greyed out.
Please let me know if I'm missing something. Thanks.
The log below is for iOS11.1. Also had the same issue on iOS10.
Error below:
```
Exception Name: AssertionFailedException
Exception Reason: An assertion failed.
Exception with Assertion: {
"Assertion Criteria" : "assertWithMatcher:!((enabled && !(((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(!(enabled))))))",
"Element Matcher" : "(respondsToSelector(accessibilityIdentifier) && accessibilityID('Done'))"
}
Exception Details: Error Trace: [
{
"Description" : "Assertion with matcher [M] failed: UI element [E] failed to match the following matcher(s): [S]",
"Description Glossary" : {
"M" : "!((enabled && !(((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(!(enabled))))))",
"E" : "",
"S" : "!((enabled && !(((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(!(enabled))))))"
},
"Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
"Error Code" : "3",
"File Name" : "GREYAssertions.m",
"Function Name" : "+[GREYAssertions grey_createAssertionWithMatcher:]_block_invoke",
"Line" : "75",
"TestCase Class" : "iOSClientTest.SingleInputFieldTest",
"TestCase Method" : "testTypeVoiceDictationIndicator"
}
]
Bundle ID: com.xxxxxxxx
Stack Trace: (
0 EarlGrey 0x0000000106e7e264 -[GREYDefaultFailureHandler handleException:details:] + 1972
1 EarlGrey 0x0000000106e65428 -[GREYElementInteraction grey_handleFailureOfAssertion:assertionError:userProvidedOutError:] + 10264
2 EarlGrey 0x0000000106e5f077 __39-[GREYElementInteraction assert:error:]_block_invoke + 2839
3 EarlGrey 0x0000000106e8d294 __59-[GREYUIThreadExecutor executeSyncWithTimeout:block:error:]_block_invoke + 68
4 EarlGrey 0x0000000106e3ea33 __77-[GREYRunLoopSpinner grey_drainRunLoopInActiveModeAndCheckCondition:forTime:]_block_invoke + 467
5 EarlGrey 0x0000000106e3f8f4 __89-[GREYRunLoopSpinner grey_setupObserverInMode:withBeforeSourcesBlock:beforeWaitingBlock:]_block_invoke + 180
6 CoreFoundation 0x000000010dec4d37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
7 CoreFoundation 0x000000010dec4c8e __CFRunLoopDoObservers + 430
8 CoreFoundation 0x000000010dea9113 __CFRunLoopRun + 1251
9 CoreFoundation 0x000000010dea89b9 CFRunLoopRunSpecific + 409
10 EarlGrey 0x0000000106e3e503 -[GREYRunLoopSpinner grey_drainRunLoopInActiveModeAndCheckCondition:forTime:] + 627
11 EarlGrey 0x0000000106e3de6c -[GREYRunLoopSpinner spinWithStopConditionBlock:] + 588
12 EarlGrey 0x0000000106e8ca0e -[GREYUIThreadExecutor executeSyncWithTimeout:block:error:] + 1422
13 EarlGrey 0x0000000106e5da92 -[GREYElementInteraction assert:error:] + 2114
14 EarlGrey 0x0000000106e5f3ed -[GREYElementInteraction assertWithMatcher:error:] + 125
15 EarlGrey 0x0000000106e5f31e -[GREYElementInteraction assertWithMatcher:] + 62
16 iOSClientTest 0x000000012892f9e5 _T013iOSClientTest05BaseiaB0C18grey_check_enabledySo11GREYMatcher_p_SbtF + 229
17 iOSClientTest 0x000000012892fa79 _T013iOSClientTest05BaseiaB0C18grey_check_enabledySo11GREYMatcher_p_SbtFTo + 73
18 iOSClientTest 0x00000001289339db _T013iOSClientTest016SingleInputFieldB0C31testTypeVoiceDictationIndicatoryyF + 139
19 iOSClientTest 0x0000000128933a24 _T013iOSClientTest016SingleInputFieldB0C31testTypeVoiceDictationIndicatoryyFTo + 36
20 CoreFoundation 0x000000010dea649c __invoking___ + 140
21 CoreFoundation 0x000000010dea6370 -[NSInvocation invoke] + 320
22 EarlGrey 0x0000000106e53120 -[GREYTestCaseInvocation invoke] + 112
23 XCTest 0x000000012505b125 __24-[XCTestCase invokeTest]_block_invoke + 591
24 XCTest 0x00000001250a3a52 -[XCUITestContext performInScope:] + 183
25 XCTest 0x000000012505aecb -[XCTestCase invokeTest] + 141
26 EarlGrey 0x0000000106e45e99 -[XCTestCase(GREYAdditions) grey_invokeTest] + 1545
27 XCTest 0x000000012505be8c __26-[XCTestCase performTest:]_block_invoke.369 + 42
28 XCTest 0x00000001250a87f9 +[XCTContext runInContextForTestCase:block:] + 163
29 XCTest 0x000000012505b828 -[XCTestCase performTest:] + 608
30 XCTest 0x000000012505782e __27-[XCTestSuite performTest:]_block_invoke + 363
31 XCTest 0x0000000125057195 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 26
32 XCTest 0x0000000125057392 -[XCTestSuite performTest:] + 239
33 XCTest 0x000000012505782e __27-[XCTestSuite performTest:]_block_invoke + 363
34 XCTest 0x0000000125057195 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 26
35 XCTest 0x0000000125057392 -[XCTestSuite performTest:] + 239
36 XCTest 0x000000012505782e __27-[XCTestSuite performTest:]_block_invoke + 363
37 XCTest 0x0000000125057195 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 26
38 XCTest 0x0000000125057392 -[XCTestSuite performTest:] + 239
39 XCTest 0x00000001250aff23 __44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke + 40
40 XCTest 0x000000012506aa0e -[XCTestObservationCenter _observeTestExecutionForBlock:] + 475
41 XCTest 0x00000001250afdc2 -[XCTTestRunSession runTestsAndReturnError:] + 281
42 XCTest 0x0000000125046e87 -[XCTestDriver runTestsAndReturnError:] + 314
43 XCTest 0x00000001250a7a64 _XCTestMain + 619
44 CoreFoundation 0x000000010dec518c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
45 CoreFoundation 0x000000010dea996b __CFRunLoopDoBlocks + 203
46 CoreFoundation 0x000000010dea9144 __CFRunLoopRun + 1300
47 CoreFoundation 0x000000010dea89b9 CFRunLoopRunSpecific + 409
48 GraphicsServices 0x00000001157569c6 GSEventRunModal + 62
49 UIKit 0x000000010ff5c5e8 UIApplicationMain + 159
50 iOSClient 0x0000000105fe584f main + 111
51 libdyld.dylib 0x0000000113cd0d81 start + 1
52 ??? 0x0000000000000005 0x0 + 5
)
UI hierarchy (ordered by window level, front to back as rendered):
Legend: {
"[AX]" : "Accessibility",
"[UIE]" : "User Interaction Enabled",
"[Window 1]" : "Frontmost Window"
}
========== Window 1 ==========
|--
| |--
| | |--<_UIKBCompatInputView:0x7fc2cee83460; AX=N; AX.frame={{0, 451}, {375, 216}}; AX.activationPoint={187.5, 559}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 216}}; opaque; alpha=1>
| | | |--
| | | | |--
| | | | | |--
| | | | | | |--
| | | | | | | |--
| | | | | | | |--
| | | | | | | |--
| | | | | | | |--
| | | | | | | |--
| | | | | | | |--
| | | | | | | |--
| | | | | | | |--
| | | | | | | | |--
| | | | | | | |--
| | | | | | | | |--
| | | | | | | |--
| | | | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | | | | | |--
| | |--
| | | |--
| | | | |--
| | | | | |--
| | | | | |--
| | | | | |--
| | | | | |--
| | | | | |--<_UIBackdropEffectView:0x7fc2d3067a90; AX=N; AX.frame={{0, 451}, {375, 216}}; AX.activationPoint={187.5, 559}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 216}}; alpha=1; UIE=N>
========== Window 2 ==========
|--
| |--
| | |--<_UIRemoteKeyboardPlaceholderView:0x7fc2cefa9910; AX=N; AX.frame={{0, 451}, {375, 216}}; AX.activationPoint={187.5, 559}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 216}}; opaque; alpha=1>
========== Window 3 ==========
|--
| |--
| | |--
| | | |--
| | | | |--
| | | | | |--
| | | | |--
| | | | | |--
| | | | |--
| | | | | |--
| | | | |--
| | | | | |--
| | | | |--
| | | | | |--
| | | | |--<_UIBarBackground:0x7fc2cef042e0; AX=N; AX.frame={{0, 618}, {375, 49}}; AX.activationPoint={187.5, 642.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 49}}; opaque; alpha=1; UIE=N>
| | | | | |--
| | | | | | |--<_UIVisualEffectSubview:0x7fc2cec4bca0; AX=N; AX.frame={{0, 618}, {375, 49}}; AX.activationPoint={187.5, 642.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 49}}; opaque; alpha=1; UIE=N>
| | | | | | |--<_UIVisualEffectBackdropView:0x7fc2cec33bf0; AX=N; AX.frame={{0, 618}, {375, 49}}; AX.activationPoint={187.5, 642.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 49}}; opaque; alpha=1; UIE=N>
| | | | | |--
| | | |--
| | | | |--
| | | | | |--
| | | | | | |--
| | | | | | | |--<_UIToolbarContentView:0x7fc2d305b8b0; AX=N; AX.frame={{0, 667}, {375, 44}}; AX.activationPoint={187.5, 689}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 44}}; opaque; alpha=1>
| | | | | | | | |--<_UIButtonBarStackView:0x7fc2d30301f0; AX=N; AX.frame={{0, 667}, {375, 44}}; AX.activationPoint={187.5, 689}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 44}}; opaque; alpha=1>
| | | | | | | |--<_UIBarBackground:0x7fc2d3044b30; AX=N; AX.frame={{0, 667}, {375, 44}}; AX.activationPoint={187.5, 689}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 44}}; opaque; alpha=1; UIE=N>
| | | | | | | | |--
| | | | | | | | | |--<_UIVisualEffectSubview:0x7fc2d305b390; AX=N; AX.frame={{0, 667}, {375, 44}}; AX.activationPoint={187.5, 689}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 44}}; opaque; alpha=1; UIE=N>
| | | | | | | | | |--<_UIVisualEffectBackdropView:0x7fc2d303eb70; AX=N; AX.frame={{0, 667}, {375, 44}}; AX.activationPoint={187.5, 689}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 44}}; opaque; alpha=1; UIE=N>
| | | | | | | | |--
| | | | | | |--
| | | | | | | |--<_UINavigationBarModernPromptView:0x7fc2cef61bf0; AX=N; AX.frame={{0, 20}, {0, 0}}; AX.activationPoint={0, 20}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {0, 0}}; opaque; hidden; alpha=0>
| | | | | | | | |--
| | | | | | | |--<_UINavigationBarContentView:0x7fc2cee30150; AX=N; AX.frame={{0, 20}, {375, 44}}; AX.activationPoint={187.5, 42}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 44}}; opaque; alpha=1>
| | | | | | | | |--
| | | | | | | | | |--
| | | | | | | | | | |--
| | | | | | | | | | | |--
| | | | | | | | | | |--
| | | | | | | | | | | |--
| | | | | | | | | | | |--
| | | | | | | | | | |--
| | | | | | | | | | | |--
| | | | | | | |--<_UINavigationBarLargeTitleView:0x7fc2cef61230; AX=N; AX.frame={{0, 20}, {0, 0}}; AX.activationPoint={0, 20}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {0, 0}}; opaque; hidden; alpha=1>
| | | | | | | | |--
| | | | | | | |--<_UIBarBackground:0x7fc2cee1d510; AX=N; AX.frame={{0, 0}, {375, 64}}; AX.activationPoint={187.5, 32}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, -20}, {375, 64}}; opaque; alpha=1; UIE=N>
| | | | | | | | |--
| | | | | | | |--
| | | | | | | | |--
| | | | | | | | | |--
| | | | | | | | | | |--
| | | | | | | | | |--
| | | | | | | | | | |--
| | | | | | | | | | |--
| | | | | | | | | |--
| | | | | | | | | | |--
| | | | | | |--
| | | | | | | |--
| | | | | | | | |--
| | | | | | | | | |--
| | | | | | | | | | |--
| | | | | | | | | | |--
| | | | | | | | | | |--
| | | | | | | | | | | |--<_UITableViewCellSeparatorView:0x7fc2cef83a10; AX=N; AX.frame={{15, 144.5}, {305, 0.5}}; AX.activationPoint={167.5, 144.75}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{15, 80.5}, {305, 0.5}}; opaque; alpha=1>
| | | | | | | | | | | |--
| | | | | | | | | | | | |--
| | | | | | | | | | | | | |--
| | | | | | | | | | | | |--
| | | | | | | | | | | | | |--
| | | | | | | | | | | | | | |--
| | | | | | | | | | | | | | | |--
| | | | | | | | | | | | | | | |--
| | | | | | | | | | | | | | | | |--
| | | | | | | | | | | | | | | | | |--<_UITextFieldContentView:0x7fc2cef98160; AX=N; AX.frame={{16, 95.513671875}, {278, 42.486328125}}; AX.activationPoint={155, 116.7568359375}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {278, 42.486328125}}; alpha=1; UIE=N>
| | | | | | | | | | | | | | | | | | |--
| | | | | | | | | | | | | | | | | | | |--
| | | | | | | | | | | | | | | | |--
| | | | | | | | | | | | | | | | |--
| | | | | | | | | | | | | | | | |--
| | | | | | | | | | | | | | | | |--
| | | | | | | | | | |--
| | | | | | | | | | | |--<_UITableViewCellSeparatorView:0x7fc2d303ab10; AX=N; AX.frame={{15, 210.5}, {324, 0.5}}; AX.activationPoint={177, 210.75}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{15, 54.5}, {324, 0.5}}; opaque; alpha=1>
| | | | | | | | | | | |--
| | | | | | | | | | | | |--
| | | | | | | | | | |--
| | | | | | | | | | | |--
| | | | | | | | | | | | |--
| | | | | | | | | | | |--<_UITableViewCellSeparatorView:0x7fc2d3036590; AX=N; AX.frame={{15, 354.5}, {360, 0.5}}; AX.activationPoint={195, 354.75}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{15, 89.5}, {360, 0.5}}; opaque; alpha=1>
| | | | | | | | | | | |--
| | | | | | | | | | | | |--
| | | | | | | | | | | | | |--
| | | | | | | | | | | | | |--
| | | | | | | | | | | | |--
| | | | | | | | | | | | | |--
| |--
| | |--
Test Case '-[iOSClientTest.SingleInputFieldTest testTypeVoiceDictationIndicator]' failed (10.676 seconds).
```
Contributor guide
Assessment
This issue has not been assessed yet.