Marcin Środa

    Marcin Środa

    1 year ago
    Hey, got a question about TextField with placeholder test. How can I check is editable text empty?
    composeTestRule.onNodeWithContentDescription(inputDescription).assertTextEquals("")
    returns
    java.lang.AssertionError: Failed to assert the following: (Text + EditableText = [])
    Semantics of the node:
    Node #130 at (l=0.0, t=273.0, r=1080.0, b=420.0)px
    ContentDescription = '[message_input_text]'
    ImeAction = 'Send'
    EditableText = ''
    TextSelectionRange = 'TextRange(0, 0)'
    Focused = 'false'
    Text = '[Type Message]'
    Actions = [GetTextLayoutResult, SetText, SetSelection, OnClick, OnLongClick, PasteText]
    MergeDescendants = 'true'
    Has 1 child
    Selector used: (ContentDescription = 'message_input_text' (ignoreCase: false))
    Well, weird. The fix is quite simple- useUnmergedTree:
    composeTestRule.onNodeWithContentDescription(inputDescription, useUnmergedTree = true).assertTextEquals("")