Optimize tap loop by hoisting element finding and calculations#475
Merged
emanlove merged 2 commits intoserhatbolsu:masterfrom Mar 10, 2026
Conversation
…ate calculation. This change moves the `_element_find` call and the center coordinate calculations outside the repetition loop in the `tap` keyword. This avoids making multiple expensive Appium server calls for the same element when the `count` argument is greater than 1. Key changes: - Hoisted `self._element_find(element, True, True)` outside the loop. - Hoisted `location` and `size` retrieval and `center_x`, `center_y` calculations outside the loop. - The `driver.tap` call remains inside the loop to perform the requested number of taps at the calculated position. Performance impact: - Number of `_element_find` calls reduced from `count` to 1. - Significant reduction in network/IPC latency for multi-tap operations.
…oop-16219237186636556862
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements
This pull request makes a small adjustment to the
tapmethod in theAppiumLibrary/keywords/_touch.pyfile. The change corrects the placement of the loop that handles multiple taps when theelementis a string locator, ensuring that the element is only found once and then tapped multiple times as intended.tapmethod so that when tapping on an element found by a string locator, the element is located once and then tapped the specified number of times, improving efficiency and correctness.Fixing