android / android/android-test

Espresso will not allow you to click on an ImageView if scaleX or scaleY is set

Open
#1,120 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

### Description
Copied from https://issuetracker.google.com/issues/65023753.
- Espresso will not allow you to click on an ImageView if scaleX or scaleY is set to anything but 1.
- I have an `ImageButton` shown with a left-facing arrow that has been mirrored to face right via `android:scaleX="-1"` — Espresso claims this cannot be clicked (using `onView(withId(R.id.next)).perform(click())`) as it is less than 90% visible. However, the view looks correct on a device, the bounds are correct, and UI Automator Viewer shows that it's on-screen. Removing the `scaleX` parameter shows the same bounds in UI Automator View, but the Espresso click() works as expected.

```
Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints:
at least 90 percent of the view's area is displayed to the user.
Target view: "ImageButton{id=2131296553, res-name=done, visibility=VISIBLE, width=224, height=224, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@32d8421c, tag=null, root-is-layout-requested=false, has-input-connection=false, x=1216.0, y=0.0}"
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure through Espresso's onView(withId(R.id.next)).perform(click()) with an ImageView or ImageButton using scaleX or scaleY. Start by tracing the click action's visibility constraint; done means a transformed view is accepted when it is visibly on-screen, with a regression test covering the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.