touchAction
非推奨の警告
touchAction
コマンドは__非推奨__であり、将来のバージョンで削除される予定です。
代わりに、ポインタータイプtouch
を使用したaction
コマンドを使用することをお勧めします:
await browser.action('pointer', {
parameters: { pointerType: 'touch' }
})
Touch Action APIは、Appiumで自動化できるすべてのジェスチャーの基礎を提供します。 現在はネイティブアプリでのみ利用可能であり、ウェブアプリとの対話には使用できません。 その核心は、_アドホック_な個々のアクションを連鎖させる能力であり、これらのアクションはデバイス上のアプリケーション内の要素に適用されます。使用できる基本的なアクションは以下の通りです:
- press (要素または(x,y)または両方を渡す)
- longPress (要素または(x,y)または両方を渡す)
- tap (要素または(x,y)または両方を渡す)
- moveTo (絶対x,y座標を渡す)
- wait (ミリ秒を渡す)
- release (引数なし)
使用法
$(selector).touchAction(action)
パラメータ
名前 | タイプ | 詳細 |
---|---|---|
action | TouchActions | 実行するアクション |
例
touchAction.js
it('should do a touch gesture', async () => {
const screen = await $('//UITextbox');
// simple touch action on element
await screen.touchAction('tap');
// simple touch action using selector and x y variables
// tap location is 30px right and 20px down relative from the center of the element
await screen.touchAction({
action: 'tap', x: 30, y:20
})
// multi action on an element (drag&drop)
await screen.touchAction([
'press',
{ action: 'moveTo', x: 200, y: 300 },
'release'
])
// drag&drop to element
const otherElement = await $('//UIAApplication[1]/UIAElement[2]')
await screen.touchAction([
'press',
{ action: 'moveTo', element: otherElement },
'release'
])
});