Detox: Swipe not working on Android with version >= 17.13

Created on 25 Nov 2020  路  5Comments  路  Source: wix/Detox

Describe the bug
Calling await element(by.id('scrollview')).swipe('down') causes the following error:
java.lang.NoSuchMethodException: No such accessible method: swipeInDirection() on class: com.wix.detox.espresso.DetoxAction

Note that swipe works fine with [email protected] so it was likely introduced by [email protected]

To Reproduce

  • [x] I have tested this issue on the latest Detox release and it still reproduces

Steps to reproduce:

  1. Call swipe in a test: await element(by.id('scrollview')).swipe('down')
import React from 'react'
import {  RefreshControl, ScrollView } from 'react-native'

const Screen = function () {
  const [refresh, setRefresh] = React.useState(false)
  return (
        <ScrollView
        testID='scrollview'
        refreshControl={
            <RefreshControl
                refreshing={refreshing}
                onRefresh={() => console.log('refresh')}
                colors={['red']}
            />
        }>
      </ScrollView>
  )
}

Expected behavior
To trigger a swipe down

Device and Verbose Detox Logs

detox[22461] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] {"messageId":1,"type":"error","params":{"error":"java.lang.NoSuchMethodException: No such accessible method: swipeInDirection() on class: com.wix.detox.espresso.DetoxAction\n\tat org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:439)\n\tat org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:405)\n\tat com.wix.invoke.types.ClassTarget.execute(ClassTarget.java:23)\n\tat com.wix.invoke.types.Target.invoke(Target.java:59)\n\tat com.wix.invoke.types.Target.invoke(Target.java:55)\n\tat com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:35)\n\tat com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:26)\n\tat com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:20)\n\tat com.wix.detox.InvokeActionHandler.handle(DetoxActionHandlers.kt:55)\n\tat com.wix.detox.DetoxManager$4.run(DetoxManager.java:120)\n\tat android.os.Handler.handleCallback(Handler.java:873)\n\tat android.os.Handler.dispatchMessage(Handler.java:99)\n\tat android.os.Looper.loop(Looper.java:193)\n\tat com.wix.detox.Detox$1.run(Detox.java:214)\n\tat java.lang.Thread.run(Thread.java:764)\n\nCheck device logs for full details!\n"}}                              

detox[22461] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onTestFnFailure({
  error: Error: java.lang.NoSuchMethodException: No such accessible method: swipeInDirection() on class: com.wix.detox.espresso.DetoxAction                                                              
      at _callee13$ (/e2e/sessionTest.e2e.ts:169:47)                                                         
      at tryCatch (/node_modules/regenerator-runtime/runtime.js:63:40)                                       
      at Generator.invoke [as _invoke] (/node_modules/regenerator-runtime/runtime.js:293:22)                 
      at Generator.next (/node_modules/regenerator-runtime/runtime.js:118:21)                                
      at tryCatch (/node_modules/regenerator-runtime/runtime.js:63:40)                                       
      at invoke (/node_modules/regenerator-runtime/runtime.js:154:20)                                        
      at /node_modules/regenerator-runtime/runtime.js:189:11                                                 
      at new Promise (<anonymous>)
      at callInvokeWithMethodAndArg (/node_modules/regenerator-runtime/runtime.js:188:16)                    
      at AsyncIterator.enqueue (/node_modules/regenerator-runtime/runtime.js:211:13)                         
      at AsyncIterator.next (/node_modules/regenerator-runtime/runtime.js:118:21)                            
})

Environment (please complete the following information):

  • Detox:
  • React Native: 0.63.0
  • Node: v12.18.4
  • Device: PIXEL API 28 ASOP
  • OS: Android
  • Test-runner (select one): jest-circus
triagbug android

All 5 comments

This might be because on your machine the JS and Native sides of Detox have gone out of sync.
Could you please try to rebuild your test apk from scratch, and try again?
Best if you just run this inside your app's android (native) directory:
./gradlew clean
And then build as you normally would (I assume, detox build -c ...)

Indeed, that fixed it thanks !

@d4vidi Why is such a desync even possible? Is there any way we can make sure that Detox is rebuilt when version changes? On iOS, we take into account the version number, and rebuild whenever that changes.

@LeoNatan, we can probably implement a handshake in the Detox server, so it queries the native side version. @d4vidi, wdyt?

@noomorph that would help us provide a more descriptive error - which is important, but would obviously not have the "problem" fixed. I suggest we don't waste much more energy on this at this point.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jrobber picture jrobber  路  3Comments

rborn picture rborn  路  3Comments

lc3t35 picture lc3t35  路  4Comments

raphkr picture raphkr  路  4Comments

aamorozov picture aamorozov  路  3Comments