Cannot tap an element: Tap at [x=540.5, y=2048.0] has failed

Hello, I have problem with tapping an element in android application. In appium inspector it seems that the link is outside of form boundaries and it cannot get a tap, but in Android Studio layout inspector I see it is inside the frame. Asked some help from developer and he says this might be an issue with appium. In app it is constraint layout and the height is set to match_parent . If i move Log in link above the button, I can tap it with no problem.
Anyone have any thoughts about this? any solutions?
Appium Version 1.22.0


lets make it a bit more simple and clear. write your code and error. better check in test code then struggle with any Appium GUI app problems.

Hi, thanks for the answer. Here it is:
I use codeceptjs with appium helper
Scenario(‘Login to the app’, ({ I }) => {
I.tap(’#android.debug:id/signin_link’);
});
Errors I get:
Login to the app
I tap “#android.debug:id/signin_link”
2022-01-05T14:04:58.041Z ERROR webdriver: Request failed with status 400 due to invalid element state: Tap at [x=540.5, y=2048.0] has failed

-- FAILURES:

  1) Login on Native
       Login to the app:
     Tap at [x=540.5, y=2048.0] has failed
        at io.appium.uiautomator2.handler.Tap.safeHandle(Tap.java:65)
        at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:59)
        at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:264)

ok. lets add logs. get page source at moment of fail with:

// java
System.our.println(driver.getPageSource());

Also try enable cap:

// java
capabilities.setCapability("enableMultiWindows", true);

plus add e.g. 5 sec sleep time before find element and tap to avoid any stale element problems.

Hello,
Here is the log from run with the source:
› Started SeleniumStandaloneLauncher
Login to the app
I wait 5
I wait for visible “#android.debug:id/signin_link”
I grab source
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>

<android.widget.FrameLayout index=“0” package=“android.debug” class=“android.widget.FrameLayout” text="" checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[0,0][1080,1977]" displayed=“true”>
<android.widget.LinearLayout index=“0” package=“android.debug” class=“android.widget.LinearLayout” text="" checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[0,0][1080,1977]" displayed=“true”>
<android.widget.FrameLayout index=“0” package=“android.debug” class=“android.widget.FrameLayout” text="" checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[0,171][1080,1977]" displayed=“true”>
<android.widget.LinearLayout index=“0” package=“android.debug” class=“android.widget.LinearLayout” text="" resource-id=“android.debug:id/action_bar_root” checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[0,171][1080,1977]" displayed=“true”>
<android.widget.FrameLayout index=“0” package=“android.debug” class=“android.widget.FrameLayout” text="" resource-id=“android:id/content” checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[0,171][1080,1977]" displayed=“true”>
<android.view.ViewGroup index=“0” package=“android.debug” class=“android.view.ViewGroup” text="" resource-id=“android.debug:id/root” checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[0,171][1080,1977]" displayed=“true”>
<android.widget.FrameLayout index=“0” package=“android.debug” class=“android.widget.FrameLayout” text="" resource-id=“android.debug:id/nav_host_fragment” checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[0,171][1080,1977]" displayed=“true”>
<android.widget.FrameLayout index=“0” package=“android.debug” class=“android.widget.FrameLayout” text="" resource-id=“android.debug:id/nav_host_fragment” checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[0,171][1080,1977]" displayed=“true”>
<android.view.ViewGroup index=“0” package=“android.debug” class=“android.view.ViewGroup” text="" checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[0,171][1080,1977]" displayed=“true”>
<android.widget.ImageView index=“0” package=“android.debug” class=“android.widget.ImageView” text="" resource-id=“android.debug:id/intro_illustration” checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[176,459][904,993]" displayed=“true” />
<android.widget.TextView index=“1” package=“android.debug” class=“android.widget.TextView” text=“Flexible banen voor studenten. Snel en fair betaald.” resource-id=“android.debug:id/intro_text” checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[66,1104][1014,1482]" displayed=“true” />
<android.widget.Button index=“2” package=“android.debug” class=“android.widget.Button” text=“Profiel aanmaken” resource-id=“android.debug:id/button_registration” checkable=“false” checked=“false” clickable=“true” enabled=“true” focusable=“true” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[66,1726][1014,1902]" displayed=“true” />
<android.widget.TextView index=“3” package=“android.debug” class=“android.widget.TextView” text=“Heb je al een profiel?” resource-id=“android.debug:id/signin_info” checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[299,1946][781,1977]" displayed=“true” />
<android.widget.TextView index=“4” package=“android.debug” class=“android.widget.TextView” text=“Log in” resource-id=“android.debug:id/signin_link” checkable=“false” checked=“false” clickable=“true” enabled=“true” focusable=“true” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[471,2014][610,2082]" displayed=“true” />
</android.view.ViewGroup>
</android.widget.FrameLayout>
</android.widget.FrameLayout>
</android.view.ViewGroup>
<androidx.drawerlayout.widget.DrawerLayout index=“1” package=“android.debug” class=“androidx.drawerlayout.widget.DrawerLayout” text="" checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[0,171][1080,1977]" displayed=“true”>
<android.widget.FrameLayout index=“0” package=“android.debug” class=“android.widget.FrameLayout” text="" checkable=“false” checked=“false” clickable=“false” enabled=“true” focusable=“false” focused=“false” long-clickable=“false” password=“false” scrollable=“false” selected=“false” bounds="[0,171][1080,1977]" displayed=“true” />
</androidx.drawerlayout.widget.DrawerLayout>
</android.widget.FrameLayout>
</android.widget.LinearLayout>
</android.widget.FrameLayout>
</android.widget.LinearLayout>
</android.widget.FrameLayout>

I tap “#android.debug:id/signin_link”
2022-01-06T12:31:22.039Z ERROR webdriver: Request failed with status 400 due to invalid element state: Tap at [x=540.5, y=2048.0] has failed
[1] Retrying… Attempt #2
2022-01-06T12:31:22.406Z ERROR webdriver: Request failed with status 400 due to invalid element state: Tap at [x=540.5, y=2048.0] has failed
[1] Retrying… Attempt #3
2022-01-06T12:31:22.846Z ERROR webdriver: Request failed with status 400 due to invalid element state: Tap at [x=540.5, y=2048.0] has failed
[1] Retrying… Attempt #4
2022-01-06T12:31:23.503Z ERROR webdriver: Request failed with status 400 due to invalid element state: Tap at [x=540.5, y=2048.0] has failed
[1] Error | invalid element state: Tap at [x=540.5, y=2048.0] has failed
[1] Error | invalid element state: Tap at [x=540.5, y=2048.0] has failed
[1] Stopping recording promises
› Test failed, try to save a screenshot
› Screenshot has been saved to /var/www/nl-talent-webapp/test/screenshots/Login_to_the_app.failed.png
:heavy_multiplication_x: FAILED in 7316ms

Added wait for 5 seconds. Here is the test code:
Scenario(‘Login to the app’, async ({ I }) => {
I.wait(5);
I.waitForVisible(’#android.debug:id/signin_link’);
console.log(await I.grabSource());
I.tap(’#android.debug:id/signin_link’);
});

see something wrong.

  • [0,0][1080,1977] this is first frame of all app screen
  • [471,2014][610,2082] this is our button which looks outside visible screen

what phone it is?
BTW enable on phone in developer menu to show touches and try to tap on screen:
x=540.5, y=1800.0
x=540.5, y=1850.0
x=540.5, y=1900.0

and see where actually tap happen on screen

Android studio emulator

try tap by coordinates instead. get element center and tap by x,y

tried coordinates. same :confused:
Looking into device settings to find where the touch is going on

settings -> system -> advanced -> Developer option
Input:

  • Show taps
  • Pointer location

Here are the taps from the test with 1950 coordinate:


Next on 2000 where the click is failing:

And here is the manual tap where we can see that 2058 coordinate is visible in the screen

really strange to see element problem while we do tap by x,y.

maybe easier change emulator resolution to see if it helps?
also check with Android Studio that you have 30 SDK, and other tools up to date.
no ideas any more…

! also try switch to w3c actions -> http://appium.io/docs/en/commands/interactions/actions/

Thanks for your help. Changed the device with lower resolution and it is working. But it is a strange issue for sure… :confused:
Can be closed I guess.