question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TextInputLayout] How to simulate clicks to drawables?

See original GitHub issue

Description: How to simulate a click onto TextInputLayout end drawable? Right now I use callOnClick to test button presses, and I don’t see a corresponding method to simulate clicks to the End Drawable. I am using Robolectric as well - if that helps somehow.

Material Library version: 1.1.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pedronvelosocommented, Sep 4, 2020

Grazie! This helps. For reference on those that might find this thread, this is how I did it for pure Unit Test using Robolectric:

textViewLayout.findViewById<View>(R.id.text_input_end_icon) as CheckableImageButton).performClick()
1reaction
matpagcommented, Sep 1, 2020

My bad, I completely forgot about this. Using the internal ID is 100 times better than accessing the view with reflection

@pedronveloso You should follow this approach if it is ok for you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Click on EditText's drawable right with Espresso - Stack Overflow
The trick here is to set the app:endIconMode="custom" then add your drawable as u want. In java class: you can use the setEndIconOnClickListener ......
Read more >
TextInputLayout | Android Developers
Note: Use the setStartIconDrawable(Drawable) API in place of setting a start/left compound drawable on the EditText. When using a start icon, ...
Read more >
How To Click On Drawableright On Every Textinputedittext - ADocLib
Answer #5: Create an XML layout that contains the EditText and Image Subclass ... Description: How to simulate a click onto TextInputLayout end...
Read more >
Android TextInputLayout Example | DigitalOcean
In this tutorial, we'll be looking in depth at the features that Android TextInputLayout provides us. Android TextInputLayout is a design ...
Read more >
Espresso i - Tutorialspoint
by clicking Refactor -> Migrate to AndroidX in the menu. To migrate to Androidx, ... onView(allOf(withId("image"), hasBackground(R.drawable.your_drawable))).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found