本文へ移動

touchAction

非推奨警告

touchActionコマンドは非推奨となっており、将来のバージョンで削除される予定です。actionコマンドをポインタタイプtouchと共に使用する事を推奨します。例:

await browser.action('pointer', {
parameters: { pointerType: 'touch' }
})

タッチアクションAPIは、Appiumで自動化できるすべてのジェスチャーの基礎を提供します。現在、ネイティブアプリでのみ使用可能であり、ウェブアプリとのやり取りには使用できません。その核心は、 *アドホック* な個々のアクションをチェーンで連結し、それらをデバイス上のアプリケーション内の要素に適用する機能にあります。使用できる基本的なアクションは次のとおりです。

  • press(要素または(xy)、またはその両方 を渡す)
  • longPress(要素または(xy)、またはその両方 を渡す)
  • tap(要素または(xy)、またはその両方 を渡す)
  • moveTo(絶対xy座標を渡す)
  • wait(ms(ミリ秒単位)を渡す)
  • release(引数なし)
使用方法
browser.touchAction(action)
パラメータ
名前詳細
アクションTouchActions実行するアクション
touchAction.js
it('should do a touch gesture', async () => {
const screen = await $('//UITextbox');

// simple touch action on element
await browser.touchAction({
action: 'tap',
element: screen
});

// simple touch action x y variables
// tap location is 30px right and 20px down relative from the viewport
await browser.touchAction({
action: 'tap',
x: 30,
y:20
})

// simple touch action x y variables
// tap location is 30px right and 20px down relative from the center of the element
await browser.touchAction({
action: 'tap',
x: 30,
y:20,
element: screen
})

// multi action on an element
// drag&drop from position 200x200 down 100px on the screen
await browser.touchAction([
{ action: 'press', x: 200, y: 200 },
{ action: 'moveTo', x: 200, y: 300 },
'release'
])
});

ようこそ!お手伝いしましょうか?

WebdriverIO AI Copilot