Reputation: 33
how to press tap and hold and scroll down using webdriverio and appium. I have used a normal scroll but nothing seems to work. I can manually hold and swipe but the below commands does not work
This is what I tried, however, I am not able to achieve anything with it:
browser.touchAction([
{ action: 'longPress'},
{ action: 'moveTo', x: -10, y: 0},
{ action: 'release'}
])
}
Upvotes: 0
Views: 3671
Reputation: 5220
to swipe left with the element
8.3.2
const elem = driver.$(`~${accessibilityLabel}`)
const width = await elem.getSize('width')
const startX = width / 2
const endX = startX - 150
await elem.touchAction([
{action: 'press', x: startX, y: 0},
{action: 'wait', ms: 1000},
{action: 'moveTo', x: endX, y: 0},
'release',
])
note: start x=0 and y=0 is because the actions are relative to element
Upvotes: 0
Reputation: 11
I used this:
await browser.touchPerform([
{ action: 'press', options: { x: 500, y: 1280 }},
{ action: 'wait', options: { ms: 1000}},
{ action: 'moveTo', options: { x: 500, y: 347}},
{ action: 'release' }
]);
Upvotes: 0
Reputation: 136
public static void fingerSwipe(int startX, int startY, int endX, int endY, long timeInMillis){
PointerInput touchAction = new PointerInput(PointerInput.Kind.TOUCH, "touchAction");
Interaction moveToStart = touchAction.createPointerMove(Duration.ZERO, PointerInput.Origin.viewport(), startX, startY);
Interaction pressDown = touchAction.createPointerDown(PointerInput.MouseButton.LEFT.asArg());
Interaction moveToEnd = touchAction.createPointerMove(Duration.ofMillis(timeInMillis), PointerInput.Origin.viewport(), endX, endY);
Interaction pressUp = touchAction.createPointerUp(PointerInput.MouseButton.LEFT.asArg());
Sequence swipe = new Sequence(touchAction, 0);
swipe.addAction(moveToStart);
swipe.addAction(pressDown);
swipe.addAction(moveToEnd);
swipe.addAction(pressUp);
driver.perform(Arrays.asList(swipe));
}
I use selenium interactions package to perform a swipe using JAVA and appium. Try using something similar to above code in WebDriverIo for Appium versions - 1.15.0 and above. You just need to pass input parameters depending upon the swipe you want to perform.
'long timeInMillis' is the time period of the swipe.
Upvotes: 1
Reputation: 425
I used the following to scroll down for my appium python project
for each in range(1, 2):
driver.swipe(500, 1700, 500, 1000, 400)
Change the for loop according to the number of swipes you need
Upvotes: 1