Search code examples
androidreact-nativeautomated-testsappiumappium-android

Why swipe doesn't work with appium on Android[React-Native]?


I'm trying to make swipe by coordinates (x/y) I have found this method on the appium webite, but it doesn't work for me and shows this error: TypeError: Cannot read property 'performTouchAction' of undefined

This is my test's code:

jasmine.DEFAULT_TIMEOUT_INTERVAL = 80000;
const driver = wd.promiseChainRemote('localhost', appiumPORT);

beforeAll(async () => {
    await driver.init(appiumConfigAndroidNoReset);
    await driver.setImplicitWaitTimeout(timeToWaitForElement);
});

test('TCWSF3-uitwoering', async () => {
    try {
        await driver.sleep(15000);

        let action = new wd.TouchAction();
        action.press({x: 600, y: 500});
        action.wait({ms: 500});
        action.moveTo({x: 600, y: 1900});
        action.release();
        await action.perform();
        
    } catch(err) {
        console.log(err);
    }
}); 

This is my appium config:

platformName: 'Android',
deviceName: 'Pixel 3a',
app: '/Users/test/Desktop/APP/mobile/android/app/build/outputs/apk/app-debug.apk',
platformVersion: '11.0',
appActivity: 'fb.test.MainActivity',
appPackage: 'fb.test.test',
noReset: true, 
fullReset: false,
clearSystemFiles: true,
automationName: 'uiautomator2',
newCommandTimeout: 500,

Solution

  • I have found such solution:

          let action = new wd.TouchAction(driver);
          action.press({x: 300, y: 1600})
                .wait(500)
                .moveTo({x: 300, y: 300})
                .release()
                .perform()