Skip to content
2 changes: 1 addition & 1 deletion .github/workflows/appium_Android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ on:
push:
branches:
- 4.x
- appium-esm-migration
pull_request:
branches:
- 4.x
- clone-fix-appium-touchPerform

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
55 changes: 34 additions & 21 deletions lib/helper/Appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -1375,36 +1375,49 @@ class Appium extends Webdriver {
}

/**
* Performs a specific touch action.
* The action object need to contain the action name, x/y coordinates
* Performs a specific touch action using W3C actions.
* The actions array should contain objects describing pointer actions.
*
* Example: Tap at (100, 200)
* ```js
* I.touchPerform([{
* action: 'press',
* options: {
* x: 100,
* y: 200
* }
* }, {action: 'release'}])
*
* I.touchPerform([{
* action: 'tap',
* options: {
* element: '1', // json web element was queried before
* x: 10, // x offset
* y: 20, // y offset
* count: 1 // number of touches
* }
* }]);
* I.touchPerform([
* {
* type: 'pointer',
* id: 'finger1',
* parameters: { pointerType: 'touch' },
* actions: [
* { type: 'pointerMove', duration: 0, x: 100, y: 200 },
* { type: 'pointerDown', button: 0 },
* { type: 'pointerUp', button: 0 },
* ],
* },
* ])
* ```
*
* Example: Press and hold at (100, 200) for 500ms, then release
* ```js
* I.touchPerform([
* {
* type: 'pointer',
* id: 'finger1',
* parameters: { pointerType: 'touch' },
* actions: [
* { type: 'pointerMove', duration: 0, x: 100, y: 200 },
* { type: 'pointerDown', button: 0 },
* { type: 'pause', duration: 500 },
* { type: 'pointerUp', button: 0 }
* ],
* },
* ])
* ```
*
* Appium: support Android and iOS
*
* @param {Array} actions Array of touch actions
* @param {Array} actions Array of W3C pointer actions
*/
async touchPerform(actions) {
onlyForApps.call(this)
return this.browser.touchPerform(actions)
return this.browser.performActions(actions)
}

/**
Expand Down
18 changes: 10 additions & 8 deletions test/helper/Appium_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,19 +337,21 @@ describe('Appium', function () {
assert.ok(vy.match(/vx: -\d\d000\.0 pps/), 'to be like 21000.0 pps')
})

it('should react on touchPerform action', async () => {
it('should react on touchPerform action @quick', async () => {
await app.touchPerform([
{
action: 'press',
options: {
x: 100,
y: 200,
},
type: 'pointer',
id: 'finger1',
parameters: { pointerType: 'touch' },
actions: [
{ type: 'pointerMove', duration: 0, x: 100, y: 200 },
{ type: 'pointerDown', button: 0 },
{ type: 'pointerUp', button: 0 },
],
},
{ action: 'release' },
])
const val = await app.grabCurrentActivity()
assert.equal(val, '.HomeScreenActivity')
assert.equal(val, '.TouchGesturesActivity')
})

it('should assert when you dont scroll the document anymore', async () => {
Expand Down