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

Test failing when trying to use getAttributes() on android #3147

Closed
sergtimosh opened this issue Dec 24, 2021 · 3 comments
Closed

Test failing when trying to use getAttributes() on android #3147

sergtimosh opened this issue Dec 24, 2021 · 3 comments

Comments

@sergtimosh
Copy link

sergtimosh commented Dec 24, 2021

Describe the bug

Earlier, when getAttributes() was relevant only for iOS, I was using workaround described in detox-getprops package. Now, when we already have getAttributes available for android I was trying to refactor code to use new api for Android and I still can't due to the next issue:

DetoxRuntimeError: Test Failed: com.google.android.material.slider.Slider 70 | (<any>await element(numberInputMatcher(inputName)).getAttributes()).text : 71 | // await getText(element(numberInputMatcher(inputName))) > 72 | console.log(await element(numberInputMatcher(inputName)).getAttributes()) | ^ 73 | (await element(numberInputMatcher(inputName)).atIndex(0).getAttributes()).text 74 | }

Expected behavior

Props object retrieved.

Detox Trace-Logs

Detox logs (paste logs here)

Device logs (adb logcat)

12-24 10:22:31.433 7880 7951 I DetoxActionHandlers: at java.lang.Thread.run(Thread.java:920) 12-24 10:22:31.433 7880 7951 I DetoxActionHandlers: Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/material/slider/Slider; 12-24 10:22:31.433 7880 7951 I DetoxActionHandlers: at com.wix.detox.espresso.action.SliderAttributes.get(GetAttributesAction.kt:143)

adb logs from flipper

Test exception java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:443) 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$$inlined$let$lambda$1.run(DetoxActionsDispatcher.kt:64) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:236) at com.wix.detox.adapters.server.ActionsExecutor$1.run(DetoxActionsDispatcher.kt:50) at java.lang.Thread.run(Thread.java:923) Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/material/slider/Slider; at com.wix.detox.espresso.action.SliderAttributes.get(GetAttributesAction.kt:143) at com.wix.detox.espresso.action.GetAttributesAction.perform(GetAttributesAction.kt:35) at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:16) at androidx.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:65) at androidx.test.espresso.ViewInteraction.access$100(ViewInteraction.java:15) at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:3) at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:2) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:236) at android.app.ActivityThread.main(ActivityThread.java:7904) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.material.slider.Slider" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.base.jar", zip file "/data/app/~~cKeisWq_XsZnxP1iccV_UA==/com.company_name_software.template.test-bk0vgB3hLCjmehCxsyFyiw==/base.apk", zip file "/data/app/~~HPlEJcsMIWP3D6_aFGB6iQ==/com.company_name_software.template-4FY6xvXPTEewNH2EYjhpTA==/base.apk"],nativeLibraryDirectories=[/data/app/~~cKeisWq_XsZnxP1iccV_UA==/com.company_name_software.template.test-bk0vgB3hLCjmehCxsyFyiw==/lib/arm64, /data/app/~~HPlEJcsMIWP3D6_aFGB6iQ==/com.company_name_software.template-4FY6xvXPTEewNH2EYjhpTA==/lib/arm64, /data/app/~~cKeisWq_XsZnxP1iccV_UA==/com.company_name_software.template.test-bk0vgB3hLCjmehCxsyFyiw==/base.apk!/lib/arm64-v8a, /data/app/~~HPlEJcsMIWP3D6_aFGB6iQ==/com.company_name_software.template-4FY6xvXPTEewNH2EYjhpTA==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) ... 15 more

Device logs (paste logs here)

Screenshots / Video

Located element.
image

Environment

  • Detox: 19.3.1
  • React Native: 0.63.2
  • Node: v14.18.2
  • Device: emulator @Pixel_3a_API_30
  • OS: Mac OS Monterey
  • Test-runner (select one): jest-circus
@jonathanmos
Copy link
Contributor

Looks like #2846

Please try adding the following to your app/build.gradle:

implementation 'com.google.android.material:material:1.3.0'

and check whether it fixes the issue for you

@jonathanmos jonathanmos self-assigned this Jan 2, 2022
@sergtimosh
Copy link
Author

@jonathanmos, thank you, this did the trick for me.

@SmartArray
Copy link

Looks like #2846

Please try adding the following to your app/build.gradle:

implementation 'com.google.android.material:material:1.3.0'

and check whether it fixes the issue for you

Would be great if we could opt out the use of google material.
Is there a way to only add this dependency for androidTest?

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

No branches or pull requests

4 participants