feat(longPressOn): add configurable duration parameter#3114
Open
Matheeusb wants to merge 7 commits intomobile-dev-inc:mainfrom
Open
feat(longPressOn): add configurable duration parameter#3114Matheeusb wants to merge 7 commits intomobile-dev-inc:mainfrom
Matheeusb wants to merge 7 commits intomobile-dev-inc:mainfrom
Conversation
Add optional duration parameter (in milliseconds) to TapOnElementCommand, TapOnPointV2Command, and TapOnPointCommand to support custom long press duration. - Added duration: Long? = null to TapOnElementCommand, TapOnPointV2Command and TapOnPointCommand - Added DEFAULT_LONG_PRESS_DURATION_MS = 3000L constant to TapOnElementCommand Resolves mobile-dev-inc#3083
Update Driver interface and all implementations to accept a configurable duration for long press operations instead of a hardcoded 3000ms value. - Driver.kt: updated longPress signature to longPress(point, durationMs = 3000L) - Maestro.kt: added longPressDurationMs parameter through the entire tap chain (tap, tapOnRelative, performTap, hierarchyBasedTap, screenshotBasedTap) - AndroidDriver: pass durationMs to 'input swipe' shell command - IOSDriver: pass durationMs to iosDevice.longPress() - WebDriver: pass durationMs to Selenium clickAndHold pause - CdpWebDriver: pass durationMs to Selenium clickAndHold pause Resolves mobile-dev-inc#3083
…estrator Add support for parsing the duration field from YAML and passing it through the orchestra layer to the Maestro client. - YamlElementSelector.kt: added duration: Long? field for longPressOn YAML config - YamlFluentCommand.kt: extract duration from YamlElementSelector and pass it to TapOnElementCommand and TapOnPointV2Command - Orchestra.kt: pass command.duration as longPressDurationMs to all maestro.tap() call sites (element tap, point tap, relative tap) Resolves mobile-dev-inc#3083
Update the FakeDriver used in tests to record the durationMs alongside the point in LongPress events, enabling assertions on the pressed duration. - FakeDriver.kt: updated Event.LongPress data class to include durationMs field - FakeDriver.kt: updated longPress() override to forward durationMs parameter Resolves mobile-dev-inc#3083
Add test coverage for the new duration parameter in longPressOn command. - 033_longPressOn_withDuration.yaml: test fixture with long press by text, by id, with default duration, and on a screen point, all using the duration field - YamlCommandReaderTest.kt: new test verifying that duration values are correctly parsed into TapOnElementCommand and TapOnPointV2Command, and that omitting duration results in null (defaults to 3000ms at runtime) Resolves mobile-dev-inc#3083
d4a4c51 to
5a5ab9f
Compare
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.
Summary
Fixes #3083
The
longPressOncommand had a hardcoded 3-second duration with no way to configure it. This prevented users from automating workflows that require longer (or shorter) press durations, such as bypassing Human Security challenges that require extended presses.Changes
New YAML API
Users can now specify a
durationfield (in milliseconds) onlongPressOn:Modules changed
maestro-orchestra-modelsduration: Long?toTapOnElementCommand,TapOnPointV2Command,TapOnPointCommand; addedDEFAULT_LONG_PRESS_DURATION_MS = 3000Lconstantmaestro-clientDriverinterface:longPress(point, durationMs = 3000L); propagatedlongPressDurationMsthrough alltap()overloads and intohierarchyBasedTap/screenshotBasedTapmaestro-client(drivers)AndroidDriver,IOSDriver,WebDriver,CdpWebDriver— all now use the passeddurationMsinstead of the hardcoded3000maestro-orchestraYamlElementSelector— newdurationfield;YamlFluentCommand— extracts and passesduration;Orchestra— passescommand.durationto all tap call sitesmaestro-testFakeDriver.Event.LongPressnow capturesdurationMsfor test assertionsTests
033_longPressOn_withDuration.yamlfixture covering duration on element-by-text, element-by-id, default (null), and screen-point variantslongPressOn with custom duration should parse duration into commandtest inYamlCommandReaderTestBackward compatibility
Fully backward compatible. Omitting
durationpreserves the existing 3000ms default behaviour.