Repository navigation
fix: prefer Appium events endpoint in driver.events with getSession fallback - #1382
Closed
RainyMarks wants to merge 1 commit into
Closed
RainyMarks wants to merge 1 commit into
RainyMarks wants to merge 1 commit into
Conversation
Member
|
Thank you, but I'd like to include appium 4 related changes in #1388 so closing this PR |
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
Updates
Session.events(driver.eventsinappium/webdriver/extensions/session.py) to queryPOST /session/$sessionId/appium/events(Command.GET_EVENTS) first and fall back toGET /session/$sessionId(Command.GET_SESSION) only when the server rejects the events endpoint withUnknownMethodException.Why
GET /session/:sessionIdroute and theappium:eventTimingscapability (refactor(base-driver)!: remove deprecated getSession command appium#22725), recommendinggetLogEvents(POST /session/:sessionId/appium/events) instead.driver.eventscurrently only callsGET /session/$sessionId, so against Appium 4 it fails and logs a warning before silently returning{}.POST /session/$sessionId/appium/eventshas been supported since Appium 1.16.0 and returns the event history object directly undervaluewithout requiringappium:eventTimings.GET /session/$sessionIdonUnknownMethodExceptionpreserves backwards compatibility with older servers while avoiding unnecessary legacy requests on Appium 1.16–4.x.Changes
appium/webdriver/extensions/session.py:Command.GET_EVENTSalongsideCommand.GET_SESSIONinSession._add_commands().Command.GET_EVENTSwith an empty JSON object body ({}) first, validate thatvalueis adict, and fall back toCommand.GET_SESSIONonUnknownMethodException.{}return behavior on missing/invalid payloads or non-method errors.test/unit/webdriver/webdriver_test.py:driver.eventsusesPOST /session/$sessionId/appium/eventswith{}even whenGET /session/$sessionIdreturns404 unknown command.GET /session/$sessionIdwhenPOST /session/$sessionId/appium/eventsreturns404 unknown command.{}without spurious fallback requests.Testing
ruff check .— passed.ruff format --check .— passed (399 files already formatted).mypy appium— passed (0 issues across 320 source files).pytest test/unit/webdriver/webdriver_test.py test/unit/webdriver/log_events_test.py— 45/45 passed.