![](/img/trans.png)
[英]How to “tap” and/or “press” a button using Appium / webdriverio?
[英]how to press tap and hold and scroll down using webdriverio and appium
如何使用 webdriverio 和 appium 按住並向下滾動。 我使用了普通卷軸,但似乎沒有任何效果。 我可以手動按住並滑動,但以下命令不起作用
這是我嘗試過的,但是,我無法用它實現任何目標:
browser.touchAction([
{ action: 'longPress'},
{ action: 'moveTo', x: -10, y: 0},
{ action: 'release'}
])
}
我使用以下內容向下滾動我的 appium python 項目
for each in range(1, 2):
driver.swipe(500, 1700, 500, 1000, 400)
根據您需要的滑動次數更改 for 循環
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));
}
我使用 selenium 交互包來使用 JAVA 和 appium 執行滑動。 嘗試在 Appium 版本的 WebDriverIo 中使用類似於上面的代碼 - 1.15.0 及更高版本。 您只需要根據要執行的滑動來傳遞輸入參數。
'long timeInMillis' 是滑動的時間段。
我用過這個:
await browser.touchPerform([
{ action: 'press', options: { x: 500, y: 1280 }},
{ action: 'wait', options: { ms: 1000}},
{ action: 'moveTo', options: { x: 500, y: 347}},
{ action: 'release' }
]);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.