Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Espresso clicks on the wrong location for rotated views #403

Open
TWiStErRob opened this issue Jul 2, 2019 · 1 comment
Open

Espresso clicks on the wrong location for rotated views #403

TWiStErRob opened this issue Jul 2, 2019 · 1 comment

Comments

@TWiStErRob
Copy link
Contributor

Description

I'm trying to find out what happened to this issue:
https://issuetracker.google.com/issues/64758984
(related: https://stackoverflow.com/q/42626452/253468)

It says fixed for a year now, yet Espresso 3.1.1 (latest stable atm) doesn't work. The code of GeneralLocation is exactly as described in the issue. I tried to search the history for the bug IDs but couldn't find any trace of the fix. Can you please help me find the fix, which version has the fix, whether it's released, or really any info? No mention in release notes either.

Steps to Reproduce

see https://issuetracker.google.com/issues/64758984

Expected Results

clicks correctly

Actual Results

perform(click()) passes, but OnClickListener not triggered

AndroidX Test and Android OS Versions

3.1.1, API 25

Link to a public git repo demonstrating the problem:

https://github.com/duanbo1983/espresso-click-sample

@sarn0ld
Copy link

sarn0ld commented Feb 1, 2021

There is a workaround from StackOverflow:
https://stackoverflow.com/a/55084395/2531709

Kotlin Version:


/**
 * Espresso has problems clicking on rotated image buttons:
 * https://issuetracker.google.com/issues/64758984
 * This is a workaround
 *
 */
fun forceClick(): ViewAction {
    return object : ViewAction {
        override fun getConstraints(): Matcher<View> {
            return allOf(isClickable(), isEnabled())
        }

        override fun getDescription(): String {
            return "force click"
        }

        override fun perform(uiController: UiController, view: View) {
            view.performClick()
            uiController.loopMainThreadUntilIdle()
        }
    }
}

Use with onView(R.id.my_rotated_image_button).perform(forceClick())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants