長押し
画面上の指定された要素に対して長押しジェスチャーを実行します。
これは選択された要素に対してWebDriverのaction
コマンドを発行します。これはclick
コマンドに基づいています。
情報
このコマンドは以下の最新コンポーネントでのみ動作します:
- Appiumサーバー(バージョン2.0.0以上)
appium-uiautomator2-driver
(Android用)appium-xcuitest-driver
(iOS用)
互換性の問題を避けるため、ローカルまたはクラウドベースのAppium環境を定期的に更新してください。
使用法
$(selector).longPress({ x, y, duration })
パラメータ
名前 | タイプ | 詳細 |
---|---|---|
options 省略可能 | LongPressOptions | 長押しオプション(省略可能) |
options.x 省略可能 | number | 数値(省略可能) |
options.y 省略可能 | number | 数値(省略可能) |
options.duration 省略可能 | number | 押す時間(ミリ秒)、デフォルトは1500ミリ秒 モバイルのみ |
例
longpress.offset.js
it('should demonstrate a longPress using an offset on the iOS Contacts icon', async () => {
const contacts = $('~Contacts')
// opens the Contacts menu on iOS where you can quickly create
// a new contact, edit your home screen, or remove the app
// clicks 30 horizontal and 10 vertical pixels away from location of the icon (from center point of element)
await contacts.longPress({ x: 30, y: 10 })
})
longpress.example.js
it('should be able to open the contacts menu on iOS by executing a longPress of 5 seconds', async () => {
const contacts = $('~Contacts')
// opens the Contacts menu on iOS where you can quickly create
// a new contact, edit your home screen, or remove the app
await contacts.longPress({ duration: 5 * 1000 })
})