diff --git a/AppiumLibrary/keywords/_touch.py b/AppiumLibrary/keywords/_touch.py index 3c744dc..ba3ed02 100644 --- a/AppiumLibrary/keywords/_touch.py +++ b/AppiumLibrary/keywords/_touch.py @@ -326,12 +326,12 @@ def tap(self, element: Union[str, list], count:int = 1, duration=timedelta(secon raise ValueError(f"Invalid coordinates format: {element}. Expected a list like [x, y]") elif isinstance(element, str): + el = self._element_find(element, True, True) + location = el.location + size = el.size + center_x = location['x'] + size['width'] // 2 + center_y = location['y'] + size['height'] // 2 for _ in range(count): - el = self._element_find(element, True, True) - location = el.location - size = el.size - center_x = location['x'] + size['width'] // 2 - center_y = location['y'] + size['height'] // 2 driver.tap([(center_x, center_y)], duration.total_seconds() * 1000) else: