Skip to content
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

typeText and clearText sometimes fail due to keyboard sync #39

Closed
talkol opened this issue Oct 7, 2016 · 15 comments
Closed

typeText and clearText sometimes fail due to keyboard sync #39

talkol opened this issue Oct 7, 2016 · 15 comments
Assignees

Comments

@talkol
Copy link

talkol commented Oct 7, 2016

We sometimes have sync problems with the keyboard not shown yet:

2016-10-08 01:47:39.567 example[38497:4275833] Detox Test Failed: Element matcher: (respondsToSelector(accessibilityIdentifier) && accessibilityID("UniqueId005")) Complete Error: Error Domain=com.google.earlgrey.ElementInteractionErrorDomain Code=1 "Failed to type string "�����������������", because keyboard was not shown on screen." UserInfo={NSLocalizedDescription=Failed to type string "�����������������", because keyboard was not shown on screen.}

@talkol talkol self-assigned this Oct 7, 2016
@talkol talkol added this to the Version 1 milestone Oct 7, 2016
@LeoNatan
Copy link
Contributor

LeoNatan commented Oct 9, 2016

Hopefully will be fixed with #37.

@talkol Shouldn't this target version 2, together with #37?

@LeoNatan LeoNatan modified the milestones: Version 2, Version 1 Oct 9, 2016
@talkol
Copy link
Author

talkol commented Oct 9, 2016

not sure, I think it's a different problem

talkol pushed a commit that referenced this issue Oct 9, 2016
@rotemmiz
Copy link
Member

@talkol @LeoNatan did any of you see failure in tests recently ?

@LeoNatan
Copy link
Contributor

Not that I can remember. @rotemmiz

@LeoNatan LeoNatan closed this as completed Apr 4, 2017
@mhyousefi
Copy link

mhyousefi commented Jul 31, 2017

I also have this problem.

I can find the element meaning

await expect(element(by.id('<testID>'))).toBeVisible()

works but when I try

await element(by.id('testID')).typeText(<someString>)

I get the above error with keyboard out of sync.

@rotemmiz
Copy link
Member

What error exactly are you getting ? Note that your computer keyboard layout must be on qwerty english for EarlGrey to be able to type the text.

@mhyousefi
Copy link

mhyousefi commented Jul 31, 2017

FiestTest
    1) Enter phone number and tap on button


  0 passing (15s)
  1 failing

  1) FiestTest Enter phone number and tap on button:
     Error: An action failed. Please refer to the error trace below.
Exception with Action: {
  "Action Name" : "Type '6219'",
  "Element Matcher" : "(((respondsToSelector(accessibilityIdentifier) && accessibilityID('ValidatePage-txtField')) && !(kindOfClass('RCTScrollView'))) || (kindOfClass('UIScrollView') && ((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(((respondsToSelector(accessibilityIdentifier) && accessibilityID('ValidatePage-txtField')) && kindOfClass('RCTScrollView'))))))"
}

Error Trace: [
  {
    "Description" : "Failed to type string '6219', because keyboard was not shown on screen.",
    "Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
    "Error Code" : "2",
    "File Name" : "GREYKeyboard.m",
    "Function Name" : "+[GREYKeyboard typeString:inFirstResponder:error:]",
    "Line" : "168"
  }
]

@LeoNatan
Copy link
Contributor

This can happen if you’ve played around with CMD+H (soft keyboard) or CMD+SHIFT+H (hardware keyboard). Restore those to default and make sure that the keyboard appears on screen when making a text field a first responder. Or use replaceText.

@mhyousefi
Copy link

mhyousefi commented Aug 7, 2017

I haven't really used the keys CMD+H or CMD+SHIFT+H in my simulations and when I use replaceTextinstead of typeText I get the following error:

[
    {
        "Description" : "Cannot perform action due to constraint(s) failure.",
        "Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
        "Error Code" : "1",
        "File Name" : "GREYBaseAction.m",
        "Function Name" : "-[GREYBaseAction satisfiesConstraintsForElement:error:]",
        "Line" : "66"
    }
]

For now I'm just using a sleep command like bellow to give me time to manually insert the string; but, this should not be a permanent solution...

function sleep (ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}

await sleep(milliseconds)
// what needs to happen after I manually enter the code

@rdamborsky
Copy link

I don't remember toggling keyboard setting as @LeoNatan mentions. However, when I check Hardware/Keyboard in my simulator, I can see that SW keyboard is turned off.

It made sense to turn it on, and I could see the difference right away, when focusing on input field.

Running my test case after this change, it worked as I would expect.

@mhyousefi
Copy link

Hardware -> Keyboard -> has three options:

  1. Uses the Same Layout as MacOS
  2. Connect Hardware Keyboard
  3. Toggle Software Keyboard

The third one is greyed out and the second one doesn't seem to work.

@isnifer
Copy link
Contributor

isnifer commented Aug 19, 2017

I have always click on the input before type text on the tests like humans, not robots. And don't see any problems.

@mhyousefi
Copy link

Thank you! That's exactly what I needed.
Problem solved.

@mrozbarry
Copy link

Just going to chime in from detox 7.3.7, if I have Connect Hardware Keyboard enabled, my tests usually fail, and if I disable it, the software keyboard always does the right thing. I did write a helper method to write to an input that does a tap() first, as recommended by @isnifer .

I'd prefer to have this setting enabled, since I usually run through the app manually to find where the next set of e2e tests should be, which always requires me to run my app through a login step.

Is this still an issue? I can toggle things for now, but it's just another step that I need to document for my dev team.

@rotemmiz
Copy link
Member

rotemmiz commented Jun 4, 2018

Hey @mrozbarry, it makes it hard for us to track progress of closed issues.
So if you have any progress regarding keyboard handling please open a new issue, or even better, if you want to offer a PR with bug fix or documentation we'll gladly accept it.

@wix wix locked and limited conversation to collaborators Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants