Skip to content

Swipe#

SwipeGestures #

Access swipe related gestures.

Source code in src/interaction/gesture/swipe.py
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
class SwipeGestures:
    """Access swipe related gestures."""

    def __init__(self, driver: WebDriver, platform: str) -> None:
        """
        Initialize the SwipeGestures instance.

        Args:
            driver (WebDriver): A WebDriver instance providing access to the app.
            platform (str): The platform type ('Android' or 'iOS').

        """
        self._driver = driver
        self._platform = platform.lower()
        self._max_attempts = 5
        self._viewport = self._driver.get_window_size()
        self._viewport_width = self._viewport["width"]
        self._viewport_height = self._viewport["height"]
        self._viewport_x_mid_point = self._viewport_width // 2
        self._viewport_y_mid_point = self._viewport_height // 2
        self._crop_factors = {
            "upper_cf": CROP_FACTOR_UPPER,
            "lower_cf": CROP_FACTOR_LOWER,
            "left_cf": CROP_FACTOR_LEFT,
            "right_cf": CROP_FACTOR_RIGHT,
        }
        self._boundaries = {
            "upper": int(self._viewport_height * self._crop_factors["upper_cf"]),
            "lower": int(self._viewport_height * self._crop_factors["lower_cf"]),
            "left": int(self._viewport_width * self._crop_factors["left_cf"]),
            "right": int(self._viewport_width * self._crop_factors["right_cf"]),
        }
        self._scrollable_area = {
            "x": self._boundaries["right"] - self._boundaries["left"],
            "y": self._boundaries["lower"] - self._boundaries["upper"],
        }

    def _create_action(self) -> ActionChains:
        """
        Create an ActionChains object for the driver.

        Returns:
            ActionChains: The ActionChains object configured for the driver.

        """
        action = ActionChains(self._driver)
        action.w3c_actions = ActionBuilder(
            self._driver,
            mouse=PointerInput(interaction.POINTER_TOUCH, "touch"),
        )
        return action

    def element_into_view(
        self,
        value_a: str | None = None,
        locator_method_a: AppiumBy = None,
        value_i: str | None = None,
        locator_method_i: AppiumBy = None,
        direction: SeekDirection = SeekDirection.DOWN,
    ) -> WebDriver | None:
        """
        Swipe to bring an element into view.

        This method performs a swipe gesture to ensure that the specified
        element described by `value` is within the visible area of the app.

        The method if platform agnostic, this means you can include locators for both scenarios
        and the function will use the value of `self._platform` to determine which parameters to use.

        Suffixes `_a` and `_i` is for Android and iOS respectively.

        Args:
            value_a (str | None): The locator value for the element to swipe to view (e.g., new UiSelector().description("Day planted")).
            locator_method_a (AppiumBy | None): The method to locate the element (e.g., AppiumBy.ANDROID_UIAUTOMATOR).
            value_i (str | None): The locator value for the element to swipe to view (e.g., label == 'Flowers').
            locator_method_i (AppiumBy | None): The method to locate the element (e.g., AppiumBy.IOS_PREDICATE).
            direction (SeekDirection): The direction to scroll (e.g., SeekDirection.DOWN).

        Returns:
            WebDriver | None: The located element if found; otherwise, None.

        Raises:
            ValueError: If the specified platform is unknown or unspecified.

        Android: Supports all locator methods, however UiSelector is highly preferred.  
        iOS: Supports all locator methods, however NSPredicate is highly preferred.

        """
        if self._platform == "android":
            return self._scroll_to_android(value_a, locator_method_a, direction)

        elif self._platform == "ios":
            return self._scroll_to_ios(value_i, locator_method_i, direction)

        else:
            msg = "Unspecified or unknown platform."
            raise ValueError(msg)

    def _scroll_to_android(self, value: str, locator_method: AppiumBy, direction: SeekDirection = None) -> WebDriver | None:
        if locator_method == AppiumBy.ANDROID_UIAUTOMATOR:
            # ui_selector = kwargs.get("ui_selector").value
            query = f"new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView({value})"
            return self._driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, query)
        msg = "Locator was not of type AppiumBy.ANDROID_UIAUTOMATOR or failed to locate element within viewport,"
        "falling back to alternative method."
        logger.info(msg)
        self._fallback_scroll_to_element(value, locator_method, direction)
        return None

    def _scroll_to_ios(self, value: str, locator_method: AppiumBy, direction: SeekDirection) -> WebDriver | None:
        try:
            element = self._driver.find_element(locator_method, value)
            self._driver.execute_script(
                "mobile: scrollToElement",
                {
                    "elementId": element,
                },
            )
        except NoSuchElementException:
            msg = "Failed to locate element within viewport, falling back to alternative method."
            logger.info(msg)
            self._fallback_scroll_to_element(value, locator_method, direction)
            return None
        else:
            return element

    # def _query_builder_uiautomator(self, value: str, locator_method) -> str:
    #     ui_selector = kwargs.get("ui_selector")
    #     return f'(new UiSelector().{ui_selector}("{value}"))'

    def _fallback_scroll_to_element(self, value: str, locator_method: AppiumBy, direction: SeekDirection = None) -> WebDriver | None:
        action = self._create_action()
        for _ in range(self._max_attempts):
            try:
                element = self._driver.find_element(locator_method, value)
                element_x, element_y = calculate_element_points(element)["mid"]

                if direction in [SeekDirection.UP, SeekDirection.DOWN]:
                    self._swipe_element_into_view_vertical(action, element_y, direction)
                    return element
                elif direction in [SeekDirection.LEFT, SeekDirection.RIGHT]:  # noqa: RET505
                    self._swipe_element_into_view_horizontal(
                        action,
                        element_x,
                        direction,
                    )
                    return element
            except NoSuchElementException:
                swipe_actions = {
                    SeekDirection.UP: lambda: self._perform_navigation_partial_y(
                        action,
                        self._boundaries["upper"],
                        self._boundaries["lower"],
                        self._scrollable_area["y"] * -0.4,
                    ),
                    SeekDirection.DOWN: lambda: self._perform_navigation_partial_y(
                        action,
                        self._boundaries["lower"],
                        self._boundaries["upper"],
                        self._scrollable_area["y"] * 0.4,
                    ),
                    SeekDirection.LEFT: lambda: self._perform_navigation_partial_x(
                        action,
                        self._boundaries["left"],
                        self._boundaries["right"],
                        self._scrollable_area["x"] * -0.2,
                    ),
                    SeekDirection.RIGHT: lambda: self._perform_navigation_partial_x(
                        action,
                        self._boundaries["right"],
                        self._boundaries["left"],
                        self._scrollable_area["x"] * 0.2,
                    ),
                }
                swipe_actions[direction]()

        return None

    def up(self) -> None:
        """Perform a full upward swipe of the calculated viewport."""
        action = self._create_action()
        try:
            self._perform_navigation_full_y(
                action, self._boundaries["lower"], self._boundaries["upper"]
            )
        except (WebDriverException, KeyError, AttributeError) as e:
            self._log_and_raise(f"Failed to swipe up: {e}", e)

    def down(self) -> None:
        """Perform a full downward swipe of the calculated viewport."""
        action = self._create_action()
        try:
            self._perform_navigation_full_y(
                action, self._boundaries["upper"], self._boundaries["lower"]
            )
        except (WebDriverException, KeyError, AttributeError) as e:
            self._log_and_raise(f"Failed to swipe down: {e}", e)

    def left(self) -> None:
        """Perform a full leftward swipe of the calculated viewport."""
        action = self._create_action()
        try:
            self._perform_navigation_full_x(
                action, self._boundaries["right"], self._boundaries["left"]
            )
        except (WebDriverException, KeyError, AttributeError) as e:
            self._log_and_raise(f"Failed to swipe left: {e}", e)

    def right(self) -> None:
        """Perform a full rightward swipe of the calculated viewport."""
        action = self._create_action()
        try:
            self._perform_navigation_full_x(
                action, self._boundaries["left"], self._boundaries["right"]
            )
        except (WebDriverException, KeyError, AttributeError) as e:
            self._log_and_raise(f"Failed to swipe right: {e}", e)

    def previous(self) -> None:
        """Perform a complete swipe from the left-edge of the viewport."""
        action = self._create_action()
        try:
            self._perform_navigation_full_x(action, 0, self._viewport_width)
        except (WebDriverException, AttributeError) as e:
            self._log_and_raise(f"Failed to swipe to previous: {e}", e)

    def next(self) -> None:
        """Perform a complete swipe from the right-edge of the viewport."""
        action = self._create_action()
        try:
            self._perform_navigation_full_x(action, self._viewport_width, 0)
        except (WebDriverException, AttributeError) as e:
            self._log_and_raise(f"Failed to swipe to next: {e}", e)

    def on_element(self, element: WebElement, direction: Direction) -> None:
        """Swipe on a specific element in the given direction."""
        try:
            action = self._create_action()
            element_points = calculate_element_points(element, True)

            points_map = {
                Direction.UP: (element_points["bottom_mid"], element_points["top_mid"]),
                Direction.DOWN: (
                    element_points["top_mid"],
                    element_points["bottom_mid"],
                ),
                Direction.RIGHT: (
                    element_points["left_mid"],
                    element_points["right_mid"],
                ),
                Direction.LEFT: (
                    element_points["right_mid"],
                    element_points["left_mid"],
                ),
            }

            self._perform_navigation_on_element(action, *points_map[direction])
        except (WebDriverException, KeyError, AttributeError, ValueError) as e:
            self._log_and_raise(f"Failed to swipe on element: {e}", e)

    def _swipe_element_into_view_vertical(
        self, action: ActionChains, element_y: int, direction: SeekDirection
    ) -> None:
        """Perform vertical swipes to bring an element into view."""
        try:
            distance_to_element = element_y - self._boundaries["lower"]
            actions_total = distance_to_element / self._scrollable_area["y"]
            actions_complete = int(distance_to_element // self._scrollable_area["y"])
            actions_partial = int(
                self._scrollable_area["y"] * (actions_total - actions_complete)
            )

            start, end = (
                (self._boundaries["upper"], self._boundaries["lower"])
                if direction == SeekDirection.UP
                else (self._boundaries["lower"], self._boundaries["upper"])
            )

            if actions_total > 1:
                self._perform_navigation_full_y(action, start, end, actions_complete)
            if actions_partial > SWIPE_ACTION_THRESHOLD:
                self._perform_navigation_partial_y(action, start, end, actions_partial)
        except (
            WebDriverException,
            KeyError,
            ZeroDivisionError,
            TypeError,
            ValueError,
        ) as e:
            self._log_and_raise(f"Failed to swipe element into view vertically: {e}", e)

    def _swipe_element_into_view_horizontal(
        self, action: ActionChains, element_x: int, direction: SeekDirection
    ) -> None:
        """Perform horizontal swipes to bring an element into view."""
        try:
            distance_to_element = element_x - self._boundaries["left"]
            actions_total = distance_to_element / self._scrollable_area["x"]
            actions_complete = int(distance_to_element // self._scrollable_area["x"])
            actions_partial = int(
                self._scrollable_area["x"] * (actions_total - actions_complete)
            )

            start, end = (
                (self._boundaries["right"], self._boundaries["left"])
                if direction == SeekDirection.LEFT
                else (self._boundaries["left"], self._boundaries["right"])
            )

            if actions_total > 1:
                self._perform_navigation_full_x(action, start, end, actions_complete)
            if actions_partial > SWIPE_ACTION_THRESHOLD:
                self._perform_navigation_partial_x(action, start, end, actions_partial)
        except (
            WebDriverException,
            KeyError,
            ZeroDivisionError,
            TypeError,
            ValueError,
        ) as e:
            self._log_and_raise(
                f"Failed to swipe element into view horizontally: {e}", e
            )

    def _perform_navigation_full_y(
        self,
        action: ActionChains,
        initial_bound: int,
        final_bound: int,
        iterations: int = 1,
    ) -> None:
        """Perform full vertical navigation swipes."""
        try:
            for _ in range(iterations):
                self._perform_swipe(
                    action,
                    (self._viewport_x_mid_point, initial_bound),
                    (self._viewport_x_mid_point, final_bound),
                )
                action.perform()
        except (WebDriverException, AttributeError, ValueError) as e:
            self._log_and_raise(f"Failed to perform full vertical navigation: {e}", e)

    def _perform_navigation_partial_y(
        self,
        action: ActionChains,
        initial_bound: int,
        final_bound: int,
        partial_percentage: int,
    ) -> None:
        """Perform a partial vertical navigation swipe."""
        try:
            self._perform_swipe(
                action,
                (self._viewport_x_mid_point, initial_bound),
                (self._viewport_x_mid_point, final_bound + partial_percentage),
            )
            action.perform()
        except (WebDriverException, AttributeError, ValueError) as e:
            self._log_and_raise(
                f"Failed to perform partial vertical navigation: {e}", e
            )

    def _perform_navigation_full_x(
        self,
        action: ActionChains,
        initial_bound: int,
        final_bound: int,
        iterations: int = 1,
    ) -> None:
        """Perform full horizontal navigation swipes."""
        try:
            for _ in range(iterations):
                self._perform_swipe(
                    action,
                    (initial_bound, self._viewport_y_mid_point),
                    (final_bound, self._viewport_y_mid_point),
                )
                action.perform()
        except (WebDriverException, AttributeError, ValueError) as e:
            self._log_and_raise(f"Failed to perform full horizontal navigation: {e}", e)

    def _perform_navigation_partial_x(
        self,
        action: ActionChains,
        initial_bound: int,
        final_bound: int,
        partial_percentage: int,
    ) -> None:
        """Perform a partial horizontal navigation swipe."""
        try:
            self._perform_swipe(
                action,
                (initial_bound, self._viewport_y_mid_point),
                (final_bound + partial_percentage, self._viewport_y_mid_point),
            )
            action.perform()
        except (WebDriverException, AttributeError, ValueError) as e:
            self._log_and_raise(
                f"Failed to perform partial horizontal navigation: {e}", e
            )

    def _perform_navigation_on_element(
        self,
        action: ActionChains,
        initial_bound: tuple[int, int],
        final_bound: tuple[int, int],
    ) -> None:
        """Perform a navigation swipe on a specific element."""
        try:
            self._perform_swipe(action, initial_bound, final_bound)
            action.perform()
        except (WebDriverException, AttributeError, ValueError) as e:
            self._log_and_raise(f"Failed to perform navigation on element: {e}", e)

    def _perform_swipe(
        self, action: ActionChains, start: tuple[int, int], end: tuple[int, int]
    ) -> None:
        """Perform a swipe action from start to end coordinates."""
        try:
            action.w3c_actions.pointer_action.move_to_location(*start)
            action.w3c_actions.pointer_action.pointer_down()
            action.w3c_actions.pointer_action.move_to_location(*end)
            action.w3c_actions.pointer_action.pause(0.5)
            action.w3c_actions.pointer_action.release()
        except (WebDriverException, AttributeError, ValueError) as e:
            self._log_and_raise(f"Failed to perform swipe action: {e}", e)

__init__(driver, platform) #

Initialize the SwipeGestures instance.

Parameters:

Name Type Description Default
driver WebDriver

A WebDriver instance providing access to the app.

required
platform str

The platform type ('Android' or 'iOS').

required
Source code in src/interaction/gesture/swipe.py
def __init__(self, driver: WebDriver, platform: str) -> None:
    """
    Initialize the SwipeGestures instance.

    Args:
        driver (WebDriver): A WebDriver instance providing access to the app.
        platform (str): The platform type ('Android' or 'iOS').

    """
    self._driver = driver
    self._platform = platform.lower()
    self._max_attempts = 5
    self._viewport = self._driver.get_window_size()
    self._viewport_width = self._viewport["width"]
    self._viewport_height = self._viewport["height"]
    self._viewport_x_mid_point = self._viewport_width // 2
    self._viewport_y_mid_point = self._viewport_height // 2
    self._crop_factors = {
        "upper_cf": CROP_FACTOR_UPPER,
        "lower_cf": CROP_FACTOR_LOWER,
        "left_cf": CROP_FACTOR_LEFT,
        "right_cf": CROP_FACTOR_RIGHT,
    }
    self._boundaries = {
        "upper": int(self._viewport_height * self._crop_factors["upper_cf"]),
        "lower": int(self._viewport_height * self._crop_factors["lower_cf"]),
        "left": int(self._viewport_width * self._crop_factors["left_cf"]),
        "right": int(self._viewport_width * self._crop_factors["right_cf"]),
    }
    self._scrollable_area = {
        "x": self._boundaries["right"] - self._boundaries["left"],
        "y": self._boundaries["lower"] - self._boundaries["upper"],
    }

down() #

Perform a full downward swipe of the calculated viewport.

Source code in src/interaction/gesture/swipe.py
def down(self) -> None:
    """Perform a full downward swipe of the calculated viewport."""
    action = self._create_action()
    try:
        self._perform_navigation_full_y(
            action, self._boundaries["upper"], self._boundaries["lower"]
        )
    except (WebDriverException, KeyError, AttributeError) as e:
        self._log_and_raise(f"Failed to swipe down: {e}", e)

element_into_view(value_a=None, locator_method_a=None, value_i=None, locator_method_i=None, direction=SeekDirection.DOWN) #

Swipe to bring an element into view.

This method performs a swipe gesture to ensure that the specified element described by value is within the visible area of the app.

The method if platform agnostic, this means you can include locators for both scenarios and the function will use the value of self._platform to determine which parameters to use.

Suffixes _a and _i is for Android and iOS respectively.

Parameters:

Name Type Description Default
value_a str | None

The locator value for the element to swipe to view (e.g., new UiSelector().description("Day planted")).

None
locator_method_a AppiumBy | None

The method to locate the element (e.g., AppiumBy.ANDROID_UIAUTOMATOR).

None
value_i str | None

The locator value for the element to swipe to view (e.g., label == 'Flowers').

None
locator_method_i AppiumBy | None

The method to locate the element (e.g., AppiumBy.IOS_PREDICATE).

None
direction SeekDirection

The direction to scroll (e.g., SeekDirection.DOWN).

DOWN

Returns:

Type Description
WebDriver | None

WebDriver | None: The located element if found; otherwise, None.

Raises:

Type Description
ValueError

If the specified platform is unknown or unspecified.

Android: Supports all locator methods, however UiSelector is highly preferred.
iOS: Supports all locator methods, however NSPredicate is highly preferred.

Source code in src/interaction/gesture/swipe.py
def element_into_view(
    self,
    value_a: str | None = None,
    locator_method_a: AppiumBy = None,
    value_i: str | None = None,
    locator_method_i: AppiumBy = None,
    direction: SeekDirection = SeekDirection.DOWN,
) -> WebDriver | None:
    """
    Swipe to bring an element into view.

    This method performs a swipe gesture to ensure that the specified
    element described by `value` is within the visible area of the app.

    The method if platform agnostic, this means you can include locators for both scenarios
    and the function will use the value of `self._platform` to determine which parameters to use.

    Suffixes `_a` and `_i` is for Android and iOS respectively.

    Args:
        value_a (str | None): The locator value for the element to swipe to view (e.g., new UiSelector().description("Day planted")).
        locator_method_a (AppiumBy | None): The method to locate the element (e.g., AppiumBy.ANDROID_UIAUTOMATOR).
        value_i (str | None): The locator value for the element to swipe to view (e.g., label == 'Flowers').
        locator_method_i (AppiumBy | None): The method to locate the element (e.g., AppiumBy.IOS_PREDICATE).
        direction (SeekDirection): The direction to scroll (e.g., SeekDirection.DOWN).

    Returns:
        WebDriver | None: The located element if found; otherwise, None.

    Raises:
        ValueError: If the specified platform is unknown or unspecified.

    Android: Supports all locator methods, however UiSelector is highly preferred.  
    iOS: Supports all locator methods, however NSPredicate is highly preferred.

    """
    if self._platform == "android":
        return self._scroll_to_android(value_a, locator_method_a, direction)

    elif self._platform == "ios":
        return self._scroll_to_ios(value_i, locator_method_i, direction)

    else:
        msg = "Unspecified or unknown platform."
        raise ValueError(msg)

left() #

Perform a full leftward swipe of the calculated viewport.

Source code in src/interaction/gesture/swipe.py
def left(self) -> None:
    """Perform a full leftward swipe of the calculated viewport."""
    action = self._create_action()
    try:
        self._perform_navigation_full_x(
            action, self._boundaries["right"], self._boundaries["left"]
        )
    except (WebDriverException, KeyError, AttributeError) as e:
        self._log_and_raise(f"Failed to swipe left: {e}", e)

next() #

Perform a complete swipe from the right-edge of the viewport.

Source code in src/interaction/gesture/swipe.py
def next(self) -> None:
    """Perform a complete swipe from the right-edge of the viewport."""
    action = self._create_action()
    try:
        self._perform_navigation_full_x(action, self._viewport_width, 0)
    except (WebDriverException, AttributeError) as e:
        self._log_and_raise(f"Failed to swipe to next: {e}", e)

on_element(element, direction) #

Swipe on a specific element in the given direction.

Source code in src/interaction/gesture/swipe.py
def on_element(self, element: WebElement, direction: Direction) -> None:
    """Swipe on a specific element in the given direction."""
    try:
        action = self._create_action()
        element_points = calculate_element_points(element, True)

        points_map = {
            Direction.UP: (element_points["bottom_mid"], element_points["top_mid"]),
            Direction.DOWN: (
                element_points["top_mid"],
                element_points["bottom_mid"],
            ),
            Direction.RIGHT: (
                element_points["left_mid"],
                element_points["right_mid"],
            ),
            Direction.LEFT: (
                element_points["right_mid"],
                element_points["left_mid"],
            ),
        }

        self._perform_navigation_on_element(action, *points_map[direction])
    except (WebDriverException, KeyError, AttributeError, ValueError) as e:
        self._log_and_raise(f"Failed to swipe on element: {e}", e)

previous() #

Perform a complete swipe from the left-edge of the viewport.

Source code in src/interaction/gesture/swipe.py
def previous(self) -> None:
    """Perform a complete swipe from the left-edge of the viewport."""
    action = self._create_action()
    try:
        self._perform_navigation_full_x(action, 0, self._viewport_width)
    except (WebDriverException, AttributeError) as e:
        self._log_and_raise(f"Failed to swipe to previous: {e}", e)

right() #

Perform a full rightward swipe of the calculated viewport.

Source code in src/interaction/gesture/swipe.py
def right(self) -> None:
    """Perform a full rightward swipe of the calculated viewport."""
    action = self._create_action()
    try:
        self._perform_navigation_full_x(
            action, self._boundaries["left"], self._boundaries["right"]
        )
    except (WebDriverException, KeyError, AttributeError) as e:
        self._log_and_raise(f"Failed to swipe right: {e}", e)

up() #

Perform a full upward swipe of the calculated viewport.

Source code in src/interaction/gesture/swipe.py
def up(self) -> None:
    """Perform a full upward swipe of the calculated viewport."""
    action = self._create_action()
    try:
        self._perform_navigation_full_y(
            action, self._boundaries["lower"], self._boundaries["upper"]
        )
    except (WebDriverException, KeyError, AttributeError) as e:
        self._log_and_raise(f"Failed to swipe up: {e}", e)