From 0b693a148a58b58d857a720035348e5f3f60de49 Mon Sep 17 00:00:00 2001 From: Mykhailo Levchun Date: Tue, 6 Feb 2024 15:01:29 +0200 Subject: [PATCH] updated performSwipe with w3c protocol v2 --- lib/helper/Appium.js | 48 +++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/lib/helper/Appium.js b/lib/helper/Appium.js index 2eae24a3d..b6f2953c4 100644 --- a/lib/helper/Appium.js +++ b/lib/helper/Appium.js @@ -2,6 +2,7 @@ let webdriverio; const fs = require('fs'); const axios = require('axios').default; +const { v4: uuidv4 } = require('uuid'); const Webdriver = require('./WebDriver'); const AssertionFailedError = require('../assert/error'); @@ -1088,17 +1089,40 @@ class Appium extends Webdriver { * Appium: support Android and iOS */ async performSwipe(from, to) { - await this.browser.touchPerform([{ - action: 'press', - options: from, - }, { - action: 'wait', - options: { ms: 1000 }, - }, { - action: 'moveTo', - options: to, - }, { - action: 'release', + await this.browser.performActions([{ + id: uuidv4(), + type: 'pointer', + parameters: { + pointerType: 'touch', + }, + actions: [ + { + duration: 0, + x: from.x, + y: from.y, + type: 'pointerMove', + origin: 'viewport', + }, + { + button: 1, + type: 'pointerDown', + }, + { + duration: 200, + type: 'pause', + }, + { + duration: 600, + x: to.x, + y: to.y, + type: 'pointerMove', + origin: 'viewport', + }, + { + button: 1, + type: 'pointerUp', + }, + ], }]); await this.browser.pause(1000); } @@ -1128,7 +1152,7 @@ class Appium extends Webdriver { yoffset = 100; } - return this.swipe(locator, 0, yoffset, speed); + return this.swipe(parseLocator.call(this, locator), 0, yoffset, speed); } /**