touchAction
Avviso di Deprecazione
Il comando touchAction
è deprecato e sarà rimosso in una versione futura.
Raccomandiamo di utilizzare invece il comando action
con
il tipo di puntatore touch
, ad esempio:
await browser.action('pointer', {
parameters: { pointerType: 'touch' }
})
L'API Touch Action fornisce la base di tutti i gesti che possono essere automatizzati in Appium. Attualmente è disponibile solo per le app native e non può essere utilizzata per interagire con le webapps. Il suo nucleo è la capacità di concatenare azioni individuali ad hoc, che verranno poi applicate a un elemento nell'applicazione sul dispositivo. Le azioni di base che possono essere utilizzate sono:
- press (passa elemento o (
x
,y
) o entrambi) - longPress (passa elemento o (
x
,y
) o entrambi) - tap (passa elemento o (
x
,y
) o entrambi) - moveTo (passa coordinate assolute
x
,y
) - wait (passa
ms
(in millisecondi)) - release (nessun argomento)
Utilizzo
browser.touchAction(action)
Parametri
Nome | Tipo | Dettagli |
---|---|---|
action | TouchActions | azione da eseguire |
Esempio
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'
])
});