longPress
Utför en långtrycksgest på det givna elementet på skärmen.
Detta utfärdar ett WebDriver action
-kommando för det valda elementet. Det är baserat på click
-kommandot.
info
Detta kommando fungerar endast med följande uppdaterade komponenter:
- Appium server (version 2.0.0 eller högre)
appium-uiautomator2-driver
(för Android)appium-xcuitest-driver
(för iOS)
Se till att din lokala eller molnbaserade Appium-miljö uppdateras regelbundet för att undvika kompatibilitetsproblem.
Användning
$(selector).longPress({ x, y, duration })
Parametrar
Namn | Typ | Detaljer |
---|---|---|
options valfri | LongPressOptions | Långtrycksalternativ (valfritt) |
options.x valfri | number | Nummer (valfritt) |
options.y valfri | number | Nummer (valfritt) |
options.duration valfri | number | Tryckets varaktighet i ms, standard är 1500 ms ENDAST-MOBIL |
Exempel
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 })
})