I know it is possible for Espresso to click by bounds the way UiAutomator does. (x and y coordinates) I have read through the documentation but I can\'t seem to find it. Any
The valid answer helped me although that method is deprecated.
Now you have to specify the inputDevice (for example InputDevice.SOURCE_MOUSE) and buttonState (for example MotionEvent.BUTTON_PRIMARY
Example in Kotlin:
companion object {
fun clickIn(x: Int, y: Int): ViewAction {
return GeneralClickAction(
Tap.SINGLE,
CoordinatesProvider { view ->
val screenPos = IntArray(2)
view?.getLocationOnScreen(screenPos)
val screenX = (screenPos[0] + x).toFloat()
val screenY = (screenPos[1] + y).toFloat()
floatArrayOf(screenX, screenY)
},
Press.FINGER,
InputDevice.SOURCE_MOUSE,
MotionEvent.BUTTON_PRIMARY)
}
}