Skip to content

fix: correct screen recording return types and documented options - #1346

Open
MattL1989 wants to merge 1 commit into
appium:masterfrom
MattL1989:fix/screen-record-types-and-options
Open

MattL1989 wants to merge 1 commit into
appium:masterfrom
MattL1989:fix/screen-record-types-and-options

Conversation

@MattL1989

Copy link
Copy Markdown
Contributor

Problem

start_recording_screen() is annotated -> bytes | str and stop_recording_screen() is annotated -> bytes. Both return the response value, which is decoded from JSON, so it can never be bytes. The drivers return the base64 video as a string. On Windows and macOS, start_recording_screen() returns nothing, which the Appium server sends as null.

With the old annotations, mypy accepts driver.stop_recording_screen().decode(), which raises AttributeError at runtime.

Several documented keyword arguments also differ from the keys the drivers read:

  • The docstring says forcedRestart. All drivers read forceRestart.
  • It says captureClick. The Windows and Mac2 drivers read captureClicks.
  • It lists videoFilters for iOS, Windows and macOS. Only XCUITest reads videoFilters; Windows and Mac2 read videoFilter. The table at the top listed videoFilter for all three.
  • It types bugReport as str. The Android driver types it as boolean.
  • It says the maximum timeLimit is 3 minutes on Android and 10 minutes on iOS. The drivers allow 1800 s and 4200 s. It also says macOS allows up to 10000 s, but Mac2 enforces no maximum.

I checked each point against the driver source:

Fix

  • Annotate start_recording_screen() as -> str | None and stop_recording_screen() as -> str, and update the Returns: sections to match.
  • Rename forcedRestart to forceRestart and captureClick to captureClicks. Note that Windows and macOS default forceRestart to True.
  • Mark videoFilters as iOS only, and add a videoFilter entry and table row for Windows and macOS.
  • Type bugReport as bool.
  • Correct the timeLimit maximums and remove the macOS maximum.

There is no runtime change. The stop_recording_screen edits do not touch the Usage block, so this merges cleanly with #1334.

Behaviour change: type-checker results change. Code that treats either result as bytes is now flagged, and code that uses the result of start_recording_screen() without handling None is flagged too.

Tests

  • On master, mypy reveals bytes | str for start_recording_screen() and bytes for stop_recording_screen(), and accepts driver.stop_recording_screen().decode(). With this change it reveals str | None and str, and reports "str" has no attribute "decode".
  • The existing unit tests already expect a str from stop and None from start.
  • The edited RST table still parses with docutils.
  • ruff check, ruff format --check, mypy appium and the full unit test suite pass.

🤖 Generated with Claude Code

The start_recording_screen and stop_recording_screen docstrings named
options that the drivers do not read, and the return annotations did
not match what the server sends.

The response value is decoded from JSON, so it is never bytes. Both
methods return the base64 string as a str, and on Windows and macOS
start_recording_screen returns None. The annotations are now
`str | None` for start and `str` for stop. There is no runtime change.

Docstring fixes:
- forcedRestart is renamed to forceRestart, the key read by the
  Android, XCUITest, Windows and Mac2 drivers. The Windows and macOS
  default of True is documented.
- captureClick is renamed to captureClicks, as read by the Windows and
  Mac2 drivers.
- videoFilters is marked iOS only. The Windows and Mac2 drivers read
  videoFilter, which now has its own entry and table row.
- bugReport is a boolean in the Android driver, not a string.
- The timeLimit maximums are those enforced by the drivers: 1800 s on
  Android and 4200 s on iOS. Mac2 enforces no maximum, so the 10000 s
  line is removed. The 600 s default also applies to Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant