Detox: How can we expect the placeholder value?

Created on 14 Aug 2017  Â·  7Comments  Â·  Source: wix/Detox

Description


.toHaveText('Password (min 8 characters)') appears not to work, at least I haven't been able to make it work. The error I get is:

Exception with Assertion: {
  "Assertion Criteria" : "assertWithMatcher:(((kindOfClass('UILabel') || kindOfClass('UITextField') || kindOfClass('UITextView')) && hasText('Password (min 8 characters)')) || (kindOfClass('RCTText') && an object with accessibilityLabel "Password (min 8 characters)"))",
  "Element Matcher" : "(((respondsToSelector(accessibilityIdentifier) && accessibilityID('auth:password-input')) && !(kindOfClass('RCTScrollView'))) || (kindOfClass('UIScrollView') && ((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(((respondsToSelector(accessibilityIdentifier) && accessibilityID('auth:password-input')) && kindOfClass('RCTScrollView'))))))"
}

Error Trace: [
  {
    "Description" : "Assertion with matcher [M] failed: UI element [E] failed to match the following matcher(s): [S]",
    "Description Glossary" :     {
      "M" : "(((kindOfClass('UILabel') || kindOfClass('UITextField') || kindOfClass('UITextView')) && hasText('Password (min 8 characters)')) || (kindOfClass('RCTText') && an object with accessibilityLabel "Password (min 8 characters)"))",
      "E" : "<RCTTextField:0x7fd4a944b010; AX=Y; AX.id='auth:password-input'; AX.label='Password (min 8 characters)'; AX.frame={{25, 180}, {270, 30}}; AX.activationPoint={160, 195}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {270, 30}}; opaque; alpha=1; text=''>",
      "S" : "kindOfClass('UILabel'), kindOfClass('UITextField'), kindOfClass('UITextView'), kindOfClass('RCTText')"
    },
    "Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
    "Error Code" : "3",
    "File Name" : "GREYAssertions.m",
    "Function Name" : "+[GREYAssertions grey_createAssertionWithMatcher:]_block_invoke",
    "Line" : "75"
  }
]

Node, Device, Xcode and macOS Versions

  • Device: iPhone SE Simulator
accepteenhancement looking for contributors

Most helpful comment

Got this error too. I think a better place to test some static attributes - unit tests.
E2E tests should contain user behavior, not simple checks that placeholder is "Password (min 8 characters)"

All 7 comments

Got this error too. I think a better place to test some static attributes - unit tests.
E2E tests should contain user behavior, not simple checks that placeholder is "Password (min 8 characters)"

@isnifer I think you're right to an extent, but in this case my placeholder changes according to user behaviour and it would be nice to be able to assert that.

@Leeds-eBooks I thought if the user does something with input placeholder should be hidden, isn't it?

@isnifer I meant user behaviour elsewhere on the screen.

@Leeds-eBooks how user behavior reflects password input placeholder?

The user can choose between logging in and signing up, and when they are signing up, the placeholder changes to suggest password constraints. But my use case is not really important – if you don't think detox should give users the option to match placeholders, just let me know and I will close this! And maybe it should be documented, as it seemed like an expected feature to me.

Good news, this was recently implemented, and will soon find its way into a release.

For now, see the API here:
https://github.com/wix/Detox/blob/DetoxNext/docs/APIRef.ActionsOnElement.md#getAttributes--ios-only

Thanks

Was this page helpful?
0 / 5 - 0 ratings