Touch Actions in Appium



An Overview of the TouchAction / MultiAction API

What is Touch Action?

TouchAction objects contain a chain of events.

In all the appium client libraries, touch objects are created and are given a chain of events.

 

What are Available Events?

The available events from the spec are:

* press

* release

* moveTo

* tap

* wait

* longPress

* cancel

* perform

 

Here’s an example of creating an action in pseudocode:

TouchAction().press(element1).moveTo(element2).release()

The above code simulates a user pressing down on an element (ex: element1), sliding their finger to another position (ex: element2), and removing their finger from the screen.

Appium performs the events in sequence. You can add a wait event to control the timing of the gesture.

moveTo coordinates are now absolute to the current position. For example, dragging from 100,100 to 200,200 can be achieved by:

.press(100,100) // Start at 100,100

.moveTo(200,200) // Passing absolute values of 200,200 ending up at 200,200

TouchAction().press(100,100).moveTo(200,200)

 

Calling the perform event sends the entire sequence of events to appium, and the touch gesture is run on your device.

TouchAction().press(100,100).moveTo(200,200).perform()

 

MultiTouch

MultiTouch objects are collections of TouchActions.

MultiTouch gestures only have two methods, add, and perform.

add is used to add another TouchAction to this MultiTouch.

When perform is called, all the TouchActions which were added to the MultiTouch are sent to appium and performed as if they happened at the same time.

Appium first performs the first event of all TouchActions together, then the second, etc.

 

Pseudocode example of tapping with two fingers:

action0 = TouchAction().tap(el)

action1 = TouchAction().tap(el)

MultiAction().add(action0).add(action1).perform()

 

Tags: ,
Leave a comment

Your email address will not be published. Required fields are marked *

Subscribe now

Receive weekly newsletter with educational materials, new courses, most popular posts, popular books and much more!

https://bridgejunks.com/ https://crownmakesense.com/ https://brithaniabookjudges.com/ https://hughesroyality.com/ https://rhythmholic.com/ https://bandar89.simnasfikpunhas.com/ https://www.100calshop.co.il/products/thailand/ https://myasociados.com/ https://solyser.com/ http://konfidence.cz/ https://muscadinepdx.com/ https://bandar89.parajesandinos.com.ve/ https://goremekoop.com/ https://oncoswisscenter.com/ https://www.turunclifehotel.com/bandar89/ https://www.houseofproducts.biz/ https://taimoormphotography.com/
BIJI18 BIJI18 BIJI18