Skip to content

Commit 25806cb

Browse files
authored
updated performSwipe with w3c protocol v2 (#4181)
1 parent dec1b88 commit 25806cb

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

Diff for: lib/helper/Appium.js

+36-12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ let webdriverio;
22

33
const fs = require('fs');
44
const axios = require('axios').default;
5+
const { v4: uuidv4 } = require('uuid');
56

67
const Webdriver = require('./WebDriver');
78
const AssertionFailedError = require('../assert/error');
@@ -1088,17 +1089,40 @@ class Appium extends Webdriver {
10881089
* Appium: support Android and iOS
10891090
*/
10901091
async performSwipe(from, to) {
1091-
await this.browser.touchPerform([{
1092-
action: 'press',
1093-
options: from,
1094-
}, {
1095-
action: 'wait',
1096-
options: { ms: 1000 },
1097-
}, {
1098-
action: 'moveTo',
1099-
options: to,
1100-
}, {
1101-
action: 'release',
1092+
await this.browser.performActions([{
1093+
id: uuidv4(),
1094+
type: 'pointer',
1095+
parameters: {
1096+
pointerType: 'touch',
1097+
},
1098+
actions: [
1099+
{
1100+
duration: 0,
1101+
x: from.x,
1102+
y: from.y,
1103+
type: 'pointerMove',
1104+
origin: 'viewport',
1105+
},
1106+
{
1107+
button: 1,
1108+
type: 'pointerDown',
1109+
},
1110+
{
1111+
duration: 200,
1112+
type: 'pause',
1113+
},
1114+
{
1115+
duration: 600,
1116+
x: to.x,
1117+
y: to.y,
1118+
type: 'pointerMove',
1119+
origin: 'viewport',
1120+
},
1121+
{
1122+
button: 1,
1123+
type: 'pointerUp',
1124+
},
1125+
],
11021126
}]);
11031127
await this.browser.pause(1000);
11041128
}
@@ -1128,7 +1152,7 @@ class Appium extends Webdriver {
11281152
yoffset = 100;
11291153
}
11301154

1131-
return this.swipe(locator, 0, yoffset, speed);
1155+
return this.swipe(parseLocator.call(this, locator), 0, yoffset, speed);
11321156
}
11331157

11341158
/**

0 commit comments

Comments
 (0)