Girija Selvakumar
Girija Selvakumar

Reputation: 31

Scroll in android using touchAction in webdriverio (javascript)

I am trying to scroll the android screen using touchAction in webdriverio. Am using the following code to perform action but it doesn't work.

driver.touchAction([ {action:'press',x:1052,y:1567}, { action: 'moveTo',x:1041, y:689}, 'release' ])

Any suggestion would be helpful

Upvotes: 1

Views: 2389

Answers (2)

Woden
Woden

Reputation: 1386

Apart from the touchAction, the touchPerform can chain operations altogether.

await driver.touchPerform([
    { action: "longPress", options: { x: 414, y: 1285 } },
    { action: "moveTo", options: { x: 427, y: 226 } },
    { action: "release", options: {} },
    {
      action: "wait",
      options: {
        ms: 100,
      },
    },
    { action: "longPress", options: { x: 414, y: 1285 } },
    { action: "moveTo", options: { x: 427, y: 226 } },
    { action: "release", options: {} },
  ]);

Upvotes: 0

Dylan Fox
Dylan Fox

Reputation: 55

Try using longPress instead of press. You may also need to preface the command with await due to to asynchronous nature. For example:

await driver.touchAction([ {action: 'longPress', x: 0, y: 1000}, { action: 'moveTo', x: 0, y: 10}, 'release' ]);

Upvotes: 3

Related Questions