longPress
Effectue un geste d'appui prolongé sur l'élément donné à l'écran.
Cela émet une commande WebDriver action
pour l'élément sélectionné. Elle est basée sur la commande click
.
info
Cette commande ne fonctionne qu'avec les composants à jour suivants :
- Serveur Appium (version 2.0.0 ou supérieure)
appium-uiautomator2-driver
(pour Android)appium-xcuitest-driver
(pour iOS)
Assurez-vous que votre environnement Appium local ou basé sur le cloud est régulièrement mis à jour pour éviter les problèmes de compatibilité.
Utilisation
$(selector).longPress({ x, y, duration })
Paramètres
Nom | Type | Détails |
---|---|---|
options optionnel | LongPressOptions | Options d'appui prolongé (optionnel) |
options.x optionnel | number | Nombre (optionnel) |
options.y optionnel | number | Nombre (optionnel) |
options.duration optionnel | number | Durée de l'appui en ms, par défaut 1500 ms MOBILE UNIQUEMENT |
Exemples
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 })
})