wix / Detox

Gray box end-to-end testing and automation framework for mobile apps
https://wix.github.io/Detox/
MIT License
11.15k stars 1.92k forks source link

Android tap, swipe, scroll, and scrollTo do not work #4240

Open juls-k opened 10 months ago

juls-k commented 10 months ago

What happened?

I was able to confirm that the detox build and test work properly on iOS. On Android, the detox build works fine, but the following error occurs in the test.

At first, I had speculated that this error was due to not finding the testID on Android. However, my first test is to find the scrollView id on the initial screen. await expect(element(by.id('dashboardScrollView'))).toBeVisible(); Given that this is successful, it seems that it's correctly identifying the testID.

What was the expected behaviour?

The tap, swipe, scroll, scrollTo function should work properly.

Was it tested on latest Detox?

Did your test throw out a timeout?

Help us reproduce this issue!

No response

In what environment did this happen?

Detox version: 20.13.1 React Native version: 0.67.5 Has Fabric (React Native's new rendering system) enabled: no Node version: v16.19.0 Device model: Samsung Galaxy Note10 Android version: 12 Test-runner (select one): jest

Detox logs

Detox logs ``` 10:14:41.289 detox[74182] E ws-client scroll to bottom error: java.lang.NoSuchMethodException: No such accessible method: perform() on class: com.wix.detox.espresso.EspressoDetox at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:439) at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:405) at com.wix.invoke.types.ClassTarget.execute(ClassTarget.java:23) at com.wix.invoke.types.Target.invoke(Target.java:59) at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:35) at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:26) at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:20) at com.wix.detox.adapters.server.InvokeActionHandler.handle(DetoxActionHandlers.kt:54) at com.wix.detox.adapters.server.ActionsExecutor.executeAction$lambda-2$lambda-1(DetoxActionsDispatcher.kt:64) at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$nk3cF8ntnfFqbJOcVqd04vjb5nY(Unknown Source:0) at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda0.run(Unknown Source:8) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at com.wix.detox.adapters.server.ActionsExecutor._init_$lambda-0(DetoxActionsDispatcher.kt:50) at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$Hi5vyewqQiQqk57AkJy_cHqNGKY(Unknown Source:0) at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda1.run(Unknown Source:4) at java.lang.Thread.run(Thread.java:920) Check device logs for full details! 10:14:41.293 detox[74182] B artifacts-manager onTestFnFailure args: ({"error":{"name":"DetoxRuntimeError"}}) 10:14:41.293 detox[74182] E artifacts-manager onTestFnFailure 10:14:41.294 detox[74182] E lifecycle test_fn error: java.lang.NoSuchMethodException: No such accessible method: perform() on class: com.wix.detox.espresso.EspressoDetox at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:439) at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:405) at com.wix.invoke.types.ClassTarget.execute(ClassTarget.java:23) at com.wix.invoke.types.Target.invoke(Target.java:59) at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:35) at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:26) at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:20) at com.wix.detox.adapters.server.InvokeActionHandler.handle(DetoxActionHandlers.kt:54) at com.wix.detox.adapters.server.ActionsExecutor.executeAction$lambda-2$lambda-1(DetoxActionsDispatcher.kt:64) at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$nk3cF8ntnfFqbJOcVqd04vjb5nY(Unknown Source:0) at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda0.run(Unknown Source:8) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at com.wix.detox.adapters.server.ActionsExecutor._init_$lambda-0(DetoxActionsDispatcher.kt:50) at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$Hi5vyewqQiQqk57AkJy_cHqNGKY(Unknown Source:0) at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda1.run(Unknown Source:4) at java.lang.Thread.run(Thread.java:920) Check device logs for full details! ```

Device logs

Device logs ``` 10-23 10:14:40.890 30580 30685 D Detox : class com.wix.detox.espresso.DetoxMatcher, matcherForTestId, [dashboardScrollView, false] 10-23 10:14:40.893 30580 30685 D Detox : class com.wix.detox.espresso.DetoxAction, scrollToEdge, [4] 10-23 10:14:40.896 30580 30685 D Detox : class com.wix.detox.espresso.EspressoDetox, perform, [(view.getTag() is "dashboardScrollView" and view has effective visibility ), com.wix.detox.espresso.DetoxAction$2@899faf9] 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: Exception 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: java.lang.NoSuchMethodException: No such accessible method: perform() on class: com.wix.detox.espresso.EspressoDetox 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:439) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:405) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at com.wix.invoke.types.ClassTarget.execute(ClassTarget.java:23) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at com.wix.invoke.types.Target.invoke(Target.java:59) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:35) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:26) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:20) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at com.wix.detox.adapters.server.InvokeActionHandler.handle(DetoxActionHandlers.kt:54) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at com.wix.detox.adapters.server.ActionsExecutor.executeAction$lambda-2$lambda-1(DetoxActionsDispatcher.kt:64) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$nk3cF8ntnfFqbJOcVqd04vjb5nY(Unknown Source:0) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda0.run(Unknown Source:8) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at android.os.Handler.handleCallback(Handler.java:938) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at android.os.Handler.dispatchMessage(Handler.java:99) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at android.os.Looper.loopOnce(Looper.java:226) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at android.os.Looper.loop(Looper.java:313) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at com.wix.detox.adapters.server.ActionsExecutor._init_$lambda-0(DetoxActionsDispatcher.kt:50) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$Hi5vyewqQiQqk57AkJy_cHqNGKY(Unknown Source:0) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda1.run(Unknown Source:4) 10-23 10:14:40.899 30580 30685 E DetoxActionHandlers: at java.lang.Thread.run(Thread.java:920) 10-23 10:14:40.901 30580 30685 I DetoxWSClient: Sending out action 'error' (ID #5) 10-23 10:14:40.906 30580 30685 I DetoxDispatcher: Done with action 'invoke' ```

More data, please!

No response

noomorph commented 10 months ago

Do you think this is a regression from 20.13.1? Could you downgrade to 20.13.0 and check again?

Please don't mix everything into one pile, try to isolate each piece that is not working as expected.

Attaching a video with your commentary would be helpful too (e.g. code, ios video vs. android video).

juls-k commented 10 months ago

@noomorph Based on your suggestion, I've removed one issue here, as the cause likely seems to be the same. I uninstalled Detox 20.13.1 and installed 20.13.0, but the problem occurs as same.

noomorph commented 10 months ago

I apologize, but your descriptions are currently quite vague, making it challenging to understand your actions and what was removed. Please try to provide more specific information in your responses to avoid any confusion. Please attach videos, code snippets and everything that we can find necessary for understanding.

juls-k commented 10 months ago

@noomorph Thank you for your efforts to help. Do I need to provide any configuration files to identify the issue? The build is successful, but an error occurs when executing the tests. The error seems to stem from the scrollTo function not working properly. This works fine on iOS.

describe('Dashboard', () => {
  beforeAll(async () => {
    await device.launchApp({
      newInstance: true,
    });
  });

  beforeEach(async () => {
    await device.reloadReactNative();
  });

  it('should have Dashboard screen', async () => {
    await waitFor(element(by.id('dashboardScrollView'))).toBeVisible().withTimeout(4000);
    await expect(element(by.id('dashboardScrollView'))).toBeVisible();
  }); // success

  it('should scroll down', async () => {
    await waitFor(element(by.id('dashboardScrollView'))).toBeVisible().withTimeout(4000);
    await element(by.id('dashboardScrollView')).scrollTo('bottom');
    await expect(element(by.text('Recent Energy History'))).toBeVisible();
  }) // fail

Here is a portion of my test code. The first test succeeds, but the second test fails. And the error message visible at that time is the part I posted in the issue.

scroll to bottom
error: java.lang.NoSuchMethodException: No such accessible method: perform() on class: com.wix.detox.espresso.EspressoDetox.
noomorph commented 10 months ago

Could you also try this version of Detox: 20.13.2-smoke.0 ?

juls-k commented 10 months ago

@noomorph I install "detox": "20.13.2-smoke.0". Before starting, I completely removed the app and ran it again. I ran detox build, and the build was successful. However, when running detox test, the result remains the same.

noomorph commented 10 months ago

Okay, so far we can conclude that you have an issue with scrollTo, and it seems that this is a reoccurence of this issue: https://github.com/wix/Detox/issues/2787. Try to pick an older version of emulator, something with Android 9, 10 or 11 – maybe that will help, as a temporary workaround.

You also mentioned that you have tap issues, but I don't see any code snippet that would demonstrate that from your code. Could you elaborate on this as well? Supposedly, the tap issues have been fixed in 20.13.1, and your bugreport seems disturbing.

juls-k commented 10 months ago

@noomorph I used scroll(400, 'down') and scrollTo('bottom') to scroll down, but both have this problem.

And it's the same with tapping. I am trying to tap the homeNavigationDropdown, which is an element directly visible in the dashboardScrollView object. await element(by.id('homeNavigationDropdown')).tap();

and error message is this.

15:32:18.840 detox[83888] E ws-client tap
  error: java.lang.NoSuchMethodException: No such accessible method: perform() on class: com.wix.detox.espresso.EspressoDetox
        at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:439)
        at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:405)
        at com.wix.invoke.types.ClassTarget.execute(ClassTarget.java:23)
        at com.wix.invoke.types.Target.invoke(Target.java:59)
        at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:35)
        at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:26)
        at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:20)
        at com.wix.detox.adapters.server.InvokeActionHandler.handle(DetoxActionHandlers.kt:54)
        at com.wix.detox.adapters.server.ActionsExecutor.executeAction$lambda-2$lambda-1(DetoxActionsDispatcher.kt:64)
        at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$nk3cF8ntnfFqbJOcVqd04vjb5nY(Unknown Source:0)
        at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda0.run(Unknown Source:8)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at com.wix.detox.adapters.server.ActionsExecutor._init_$lambda-0(DetoxActionsDispatcher.kt:50)
        at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$Hi5vyewqQiQqk57AkJy_cHqNGKY(Unknown Source:0)
        at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda1.run(Unknown Source:4)
        at java.lang.Thread.run(Thread.java:920)
juls-k commented 10 months ago

Okay, so far we can conclude that you have an issue with scrollTo, and it seems that this is a reoccurence of this issue: #2787. Try to pick an older version of emulator, something with Android 9, 10 or 11 – maybe that will help, as a temporary workaround.

You also mentioned that you have tap issues, but I don't see any code snippet that would demonstrate that from your code. Could you elaborate on this as well? Supposedly, the tap issues have been fixed in 20.13.1, and your bugreport seems disturbing.

Yes, I was using version 18 of Detox (I'm sorry, I can't remember the exact previous version number). I upgraded to 20.13.1 after seeing that the issue with the tap function was resolved.

noomorph commented 10 months ago

Hm, this starts to look more like ProGuard issue. Can you reproduce that in a debug build?

eugenezhernakov commented 10 months ago

On RN 0.71.3, Detox 20.12.0, Node v20.8.1 I am also seeing this on a .tap(), on a debug build:

    java.lang.NoSuchMethodException: No such accessible method: perform() on class: com.wix.detox.espresso.EspressoDetox
        at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:439)
        at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:405)
        at com.wix.invoke.types.ClassTarget.execute(ClassTarget.java:23)
        at com.wix.invoke.types.Target.invoke(Target.java:59)
        at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:35)
        at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:26)
        at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:20)
        at com.wix.detox.adapters.server.InvokeActionHandler.handle(DetoxActionHandlers.kt:54)
        at com.wix.detox.adapters.server.ActionsExecutor.executeAction$lambda-2$lambda-1(DetoxActionsDispatcher.kt:64)
        at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$nk3cF8ntnfFqbJOcVqd04vjb5nY(Unknown Source:0)
        at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda0.run(Unknown Source:8)
        at android.os.Handler.handleCallback(Handler.java:942)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at com.wix.detox.adapters.server.ActionsExecutor._init_$lambda-0(DetoxActionsDispatcher.kt:50)
        at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$Hi5vyewqQiQqk57AkJy_cHqNGKY(Unknown Source:0)
        at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda1.run(Unknown Source:4)
        at java.lang.Thread.run(Thread.java:1012)
eugenezhernakov commented 10 months ago

Managed to get it to work. I updated my Kotlin version in build.gradle as per https://wix.github.io/Detox/docs/introduction/project-setup to 1.9.0 to match my system and rebuilt the app with detox build --configuration android.emu.debug

juls-k commented 10 months ago

@eugenezhernakov Are you seeing that error on build process? well, I tried kotlin 1.9.0 as you said, but build is success as before. But I am seeing that error when I run test.

juls-k commented 10 months ago

Now, I'm wondering if I need to upgrade the React Native version.

eugenezhernakov commented 10 months ago

Not during build process, but when running detox test --configuration android.emu.debug Might be worth doing as 0.70.x and 0.71.x are mentioned on the docs as the officially supported versions.

juls-k commented 10 months ago

In the end, I succeeded on the emulator. I kept the Kotlin version at 1.8.0 and only changed jest to >=27.2.5 (previous setting was ^26.6.3).

However, on the attached device I kept trying, the same issue persisted even after I upgraded the Kotlin version. In the end, I decided to give up running it on a real device and proceed only with the emulator.

noomorph commented 10 months ago

So, do I understand right we're talking about reflection methods being cast over too old (or too new) APIs?

juls-k commented 10 months ago

@noomorph I don't understand what is that meaning. I just know I'm facing that error on attached device when test running.

15:32:18.840 detox[83888] E ws-client tap
  error: java.lang.NoSuchMethodException: No such accessible method: perform() on class: com.wix.detox.espresso.EspressoDetox
        at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:439)
        at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:405)
noomorph commented 10 months ago

@juls-k try to clean up both your device and your computer – delete app apk and delete test apk. Rebuild your APKs and then re-run tests.

It looks like a discrepancy between native and JS code.

We had this change in signature in September (20.12.0), so maybe you have an old code deployed to your mobile phone:

image

P.S. Another way to test that – downgrade Detox to 20.11.4 (don't rebuild anything) and re-run tests. If that works, this confirms the theory above – you just need to upload the new binaries.

ianspektor commented 10 months ago

Having same problem. Tests work fine on iOS, but on Android swipe gestures don't work (taps might not work either, but my app's first screen needs to be swiped away first to try that). They don't fail either, detox thinks it has done them and continues the script, and then some later action fails because it didn't.

Using detox 20.13.5. Tried 20.13.0 and 20.13.2-smoke.0 with no success. Tried downgrading API level from 34 to 32 (as suggested in https://github.com/wix/Detox/issues/2787#issuecomment-1785080753) with no success either. Running with node v18, react 18.2.0, react native 0.72.0 (new arch not enabled), jest 29.7.0.

Any suggestions to go around this? I don't mind having to downgrade API level or detox/jest versions.

Thanks in advance for any help!

Seraphiyra commented 10 months ago

Having same problem. Tests work fine on iOS, but on Android swipe gestures don't work (taps might not work either, but my app's first screen needs to be swiped away first to try that). They don't fail either, detox thinks it has done them and continues the script, and then some later action fails because it didn't.

Using detox 20.13.5. Tried 20.13.0 and 20.13.2-smoke.0 with no success. Tried downgrading API level from 34 to 32 (as suggested in #2787 (comment)) with no success either. Running with node v18, react 18.2.0, react native 0.72.0 (new arch not enabled), jest 29.7.0.

Any suggestions to go around this? I don't mind having to downgrade API level or detox/jest versions.

Thanks in advance for any help!

Hey @ianspektor 👋 just thought I'd let you know that it turns out simply downgrading from 33 -> 32 wasn't the solution for me. We were previously using emulators with Google API, however we switched over to using the Google Play API (and went to 32) then it worked.

May have had something to do with one of our dependencies requiring Google Play APIs to work🤷‍♀️

However, it seems odd to me as we didn't need them before 🤔

Also doesn't make sense, as there didn't seems to be any errors relating to anything like that in our trace logs that would specifically only impact swipe actions.

As you mentioned, it was as if Detox thought it had successfully completed the swipe action and carrys on with the next action, only falling over when something wasn't where we expected later.

There was a bit too many moving parts to be able troubleshoot this one for sure in my project as I think it may have been a compound effect. We were upgrading React Native from 0.69 -> 0.72.5. Then during that the yarn.lock file was regenerated and increased all the dependencies versions. This bumped us from Detox 20.0.03 -> 20.13.0

We had been holding off upgrading it recently because we were waiting for https://github.com/wix/Detox/issues/3762 Which luckily was released not long after. It then allowed us to also upgrade the API version, which we had been stuck at 31, because of the aforementioned issue.

So it could be that something else in the RN upgrade/yarn.lock file changes caused our issues with now needing to use Google Play APIs for swipe actions to work but we didn't see it until we were finally able to upgrade Detox and also upgrade the API.

Thought I'd mention this on the off chance it helps you 😅

ianspektor commented 10 months ago

Thanks for the input @Seraphiyra! I'm currently using Android 12L (Google APIs), which from what I've just read should be the one that has Google APIs and Google Play Services? The three other options all display messages recommending to use the one I'm using to test with Google Play Services. Would you know which of them made it work for you?

Currently using

image

Other options

image
aamagda commented 9 months ago

Hey @ianspektor 👋 just thought I'd let you know that it turns out simply downgrading from 33 -> 32 wasn't the solution for me. We were previously using emulators with Google API, however we switched over to using the Google Play API (and went to 32) then it worked.

@Seraphiyra Hi. Could you tell what image do you use? google_apis or google_apis_playstore?

jyotsna-hh commented 9 months ago

Hey @Seraphiyra When can we expect a resolution for this issue? It's impacting our ability to run tests on API levels 33 and 34, which is a major hurdle for us right now. Any update on the timeline for fixing this would be greatly appreciated!

stale[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

marksmayo commented 4 months ago

Adding a +1 as I'm also running into this with detox 20.13.0, trying to get some old tests up and running again :/