Search code examples
iosreact-nativeios-simulatordetox

Detox: iOS Simulator how to press Next on keyboard


After typing user email address I want Detox to move to the password field by pressing Next.

I have tried to find password field by element id and calling .tap() for focus, but the keyboard partially occludes the password field and it fails to pass 75% visibility criteria.

Error Trace: [
  {
    "Description" : "Assertion with matcher [M] failed: UI element [E] failed to match the following matcher(s): [S]",
    "Description Glossary" :     {
      "M" : "matcherForSufficientlyVisible(>=0.750000)",
      "E" : "<RCTUITextField:0x7f9abd45f190; AX=Y; AX.id='Password Input'; AX.value='your new password'; AX.frame={{42.5, 342.5}, {235, 40}}; AX.activationPoint={160, 362.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {235, 40}}; alpha=1; text=''>",
      "S" : "matcherForSufficientlyVisible(>=0.750000)"
    },
    "Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
    "Error Code" : "3",
    "File Name" : "GREYAssertions.m",
    "Function Name" : "+[GREYAssertions grey_createAssertionWithMatcher:]_block_invoke",
    "Line" : "75"
  }
]

Any idea how I can solve this? I'm using detox to test a react-native app.

Thanks.


Solution

  • Turns out it's as simple as adding \n to the end of the text input like so:

    const email = 'test@email.com';
    await element(by.id('email_input')).typeText(`${email}\n`);