Skip to content

Commit 3de75b8

Browse files
committed
fix: update appium touchPerform method to perform a specific sequence of actions
1 parent 9eb8e79 commit 3de75b8

File tree

1 file changed

+34
-21
lines changed

1 file changed

+34
-21
lines changed

lib/helper/Appium.js

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,36 +1330,49 @@ class Appium extends Webdriver {
13301330
}
13311331

13321332
/**
1333-
* Performs a specific touch action.
1334-
* The action object need to contain the action name, x/y coordinates
1333+
* Performs a specific touch action using W3C actions.
1334+
* The actions array should contain objects describing pointer actions.
13351335
*
1336+
* Example: Tap at (100, 200)
13361337
* ```js
1337-
* I.touchPerform([{
1338-
* action: 'press',
1339-
* options: {
1340-
* x: 100,
1341-
* y: 200
1342-
* }
1343-
* }, {action: 'release'}])
1344-
*
1345-
* I.touchPerform([{
1346-
* action: 'tap',
1347-
* options: {
1348-
* element: '1', // json web element was queried before
1349-
* x: 10, // x offset
1350-
* y: 20, // y offset
1351-
* count: 1 // number of touches
1352-
* }
1353-
* }]);
1338+
* I.touchPerform([
1339+
* {
1340+
* type: 'pointer',
1341+
* id: 'finger1',
1342+
* parameters: { pointerType: 'touch' },
1343+
* actions: [
1344+
* { type: 'pointerMove', duration: 0, x: 100, y: 200 },
1345+
* { type: 'pointerDown', button: 0 },
1346+
* { type: 'pointerUp', button: 0 },
1347+
* ],
1348+
* },
1349+
* ])
1350+
* ```
1351+
*
1352+
* Example: Press and hold at (100, 200) for 500ms, then release
1353+
* ```js
1354+
* I.touchPerform([
1355+
* {
1356+
* type: 'pointer',
1357+
* id: 'finger1',
1358+
* parameters: { pointerType: 'touch' },
1359+
* actions: [
1360+
* { type: 'pointerMove', duration: 0, x: 100, y: 200 },
1361+
* { type: 'pointerDown', button: 0 },
1362+
* { type: 'pause', duration: 500 },
1363+
* { type: 'pointerUp', button: 0 }
1364+
* ],
1365+
* },
1366+
* ])
13541367
* ```
13551368
*
13561369
* Appium: support Android and iOS
13571370
*
1358-
* @param {Array} actions Array of touch actions
1371+
* @param {Array} actions Array of W3C pointer actions
13591372
*/
13601373
async touchPerform(actions) {
13611374
onlyForApps.call(this)
1362-
return this.browser.touchPerform(actions)
1375+
return this.browser.performActions(actions)
13631376
}
13641377

13651378
/**

0 commit comments

Comments
 (0)