Skip to content

Conversation

@HelioGuilherme66
Copy link

Implements

Draws a path defined by a list of points, with a delay by default of 100ms between each segment.

User presses at starting point and releases at end point.

This keyword was working in Appium 1, but now, after adaptation to Appium 2, it does not draw.

@HelioGuilherme66
Copy link
Author

I have a test app and tests here

@emanlove emanlove self-assigned this Aug 12, 2025
@emanlove emanlove added need_attention Acknowledge Acknowledge within Release Notes labels Aug 12, 2025
@emanlove
Copy link
Collaborator

Hélio, we are reviewing this PR. We have some initial discussion noting we want to look at gestures and thus paths as part of a whole language of "gestures".

For those following along here, this was a recent comment I made that tries to outline some of my thinking in this area.

For gestures and paths, in particular, I have been thinking about how different applications, specifications, languages describe paths. For example in svg there are paths. How do they describe them.

And in addition to markers along path what else do we need to describe movement. Timing is one. How quickly do we move along a path. There might be other attributes we need to attach to a path (randomness, curves like Bézier). And what is one wants to describe not the time it takes to cover a path but what is they want a “resolution”. Then there is what if we want a path that is made up of other paths. How is this described.

Some paths are closed in that they go back to the starting point. Talking about points we have discussed different coordinate systems or words/syntax for describe a “point“ on the screen. For example go to this point, direction and distance, location of this element (it’s center, a corner of it - thinking of a closure point.

Then the higher level of gesturers. How do you create a two or three finger path. Given all these how you you easir write, create, debug these in the natural language of Robot Framework ..

As you can see the complexity of this I would like to get to a unified and complete language of gestures and paths that tie neatly together.

@chsinger
Copy link
Contributor

chsinger commented Aug 12, 2025

I had a quick look at the implementation and tried to fix it. This solution draws something:

def swipe_path(self, duration: int = 100, *path):
"""
Presses down at start of path and releases at end of path with delay duration.
Args:
- duration: in milliseconds, defines the swipe speed as time taken to swipe between each point of path list.
- path: name of a variable of type list, containing the coordinates sequence. List starts at X0, Y0
and ends at Xn, Yn.
Examples:
| @path = | Create List | 100 | 100 | 300 | 100 | 150 | 300 | 100 | 100 !
| Swipe Path | @{path} |
| Swipe Path | duration=200 | ${path} |
"""

   duration = float(duration) if 0 < int(duration) <= 1 else float(duration / 1000.0)
   # Validate path size
   psz = len(path)
   if psz > 1 and psz % 2 == 0:
       touch_input = PointerInput(interaction.POINTER_TOUCH, 'touch')
       actions = ActionChains(self._current_application())
       actions.w3c_actions = ActionBuilder(self._current_application(), mouse=touch_input)
       actions.w3c_actions.pointer_action.move_to_location(path[0], path[1])
       actions.w3c_actions.pointer_action.pointer_down()
       for i in range(2, psz, 2):
           actions.w3c_actions.pointer_action.move_to_location(path[i], path[i + 1])
           actions.pause(duration)
       actions.w3c_actions.pointer_action.pointer_up()
      actions.perform()
   else:
       AssertionError(f"Parameter 'path' is mandatory and must be a list of coordinates, "
                      f"meaning its size must be an even number. You provided a 'path' with length = {psz}.")

Maybe it helps to get it working with Appium 2 :)

@emanlove emanlove added this to the v4 milestone Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Acknowledge Acknowledge within Release Notes need_attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants