Saltar al contenido principal

touchAction

Advertencia de Obsolescencia

El comando touchAction está obsoleto y será eliminado en una versión futura. Recomendamos usar el comando action en su lugar con el tipo de puntero touch, por ejemplo:

await browser.action('pointer', {
parameters: { pointerType: 'touch' }
})

La API Touch Action proporciona la base de todos los gestos que se pueden automatizar en Appium. Actualmente solo está disponible para aplicaciones nativas y no se puede usar para interactuar con aplicaciones web. Su esencia es la capacidad de encadenar acciones individuales ad hoc, que luego se aplicarán a un elemento en la aplicación en el dispositivo. Las acciones básicas que se pueden usar son:

  • press (pasar elemento o (x,y) o ambos)
  • longPress (pasar elemento o (x,y) o ambos)
  • tap (pasar elemento o (x,y) o ambos)
  • moveTo (pasar coordenadas absolutas x,y)
  • wait (pasar ms (como milisegundos))
  • release (sin argumentos)
Uso
$(selector).touchAction(action)
Parámetros
NombreTipoDetalles
actionTouchActionsacción a ejecutar
Ejemplo
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'
])
});

Welcome! How can I help?

WebdriverIO AI Copilot