Skip to content

docs: fix broken README and docstring examples - #1350

Open
MattL1989 wants to merge 1 commit into
appium:masterfrom
MattL1989:docs/readme-and-docstring-examples
Open

MattL1989 wants to merge 1 commit into
appium:masterfrom
MattL1989:docs/readme-and-docstring-examples

Conversation

@MattL1989

Copy link
Copy Markdown
Contributor

Problem

Several examples in the README and docstrings do not work as written.

  • README, "Set custom AppiumConnection": the example passes init_args_for_pool_manage= (missing the final "r"), which raises TypeError: RemoteConnection.__init__() got an unexpected keyword argument 'init_args_for_pool_manage'. Fixing only the typo is not enough:
    • Selenium deprecates passing remote_server_addr and init_args_for_pool_manager to RemoteConnection(), and warns for both.
    • Selenium's RemoteConnection._get_connection_manager reads the urllib3.PoolManager arguments from a nested 'init_args_for_pool_manager' key. A flat {'retries': ...} dict is silently ignored, so the retries never apply. Selenium's own unit tests and a direct-connect test in test/unit/webdriver/webdriver_test.py use the nested form.
  • README options examples: options.platformVersion = '13.4' only sets a Python attribute, so the version never reaches to_capabilities(). This appears three times: in the pytest fixture example (iOS and Android) and in the AppiumConnection example.
  • ExtensionBase docstring: the example URLs are 'session/$sessionId/...'. RemoteConnection.execute builds the URL as f"{remote_server_addr}{path}", so the request goes to http://localhost:4723session/1234/path/to/your/custom/url. The second example also defines test_command while method_name() returns custom_method_name, so creating the driver raises AttributeError. The third example registers YourCustomCommand instead of CustomURLCommand.
  • Flutter wait_for_visible and wait_for_invisible: the timeout is documented as seconds with type float. appium-flutter-server reads it as (json['timeout'] as num?)?.toInt() in server/lib/src/models/api/wait.dart, so the fractional part is dropped and 0.5 becomes 0. appium-flutter-integration-driver passes the value through unchanged.

Fix

  • Rewrite the first AppiumConnection example to build an AppiumClientConfig with the nested init_args_for_pool_manager dict and pass it as AppiumConnection(client_config=...).
  • Change all three options.platformVersion = ... lines to options.platform_version = ....
  • Add the leading slash to every example URL in the ExtensionBase docstring, rename test_command to custom_method_name, and register CustomURLCommand in the third example.
  • Document the Flutter wait timeout as whole seconds. The float annotation is unchanged.

These are documentation changes only. scroll_till_visible is not touched.

Tests

  • I ran the corrected AppiumConnection example against a mocked /session endpoint. It creates the driver without errors or Selenium deprecation warnings, the Retry object reaches urllib3.PoolManager, and appium:platformVersion: 13.4 is sent in the new session request.
  • With the flat dict, the Retry object does not reach the pool manager.
  • XCUITestOptions() and UiAutomator2Options() with options.platformVersion = '13.4' produce no platformVersion capability. With options.platform_version = '13.4' they produce 'appium:platformVersion': '13.4'.
  • A command added with 'session/$sessionId/...' requests http://localhost:4723session/1234/.... With the leading slash it requests http://localhost:4723/session/1234/....
  • This merges cleanly with feat: mark ActionHelpers interaction shortcuts as deprecated #1333, which also edits the README.
  • ruff check, ruff format --check, mypy appium and the full unit test suite pass.

🤖 Generated with Claude Code

README "Set custom AppiumConnection":
- The example passed init_args_for_pool_manage (missing "r"), which
  raises TypeError in RemoteConnection.__init__. Selenium also
  deprecates passing remote_server_addr and init_args_for_pool_manager
  to RemoteConnection directly, and its ClientConfig reads the
  urllib3.PoolManager arguments from a nested
  'init_args_for_pool_manager' key, so a flat {'retries': ...} dict is
  silently ignored. The example now builds an AppiumClientConfig with
  the nested dict and passes it as client_config.

README options examples:
- options.platformVersion = ... only sets a Python attribute, so the
  value never reaches to_capabilities(). All three occurrences now use
  options.platform_version.

ExtensionBase docstring:
- RemoteConnection.execute builds the URL as remote_server_addr + path,
  so 'session/$sessionId/...' produced http://localhost:4723session/....
  The example URLs now start with a slash.
- The second example defined test_command but registered
  custom_method_name, which raises AttributeError when the driver
  installs the extension. The third example registered
  YourCustomCommand instead of CustomURLCommand.

Flutter wait commands:
- appium-flutter-server reads the wait timeout with
  (json['timeout'] as num?)?.toInt(), so fractions are dropped. The
  wait_for_visible and wait_for_invisible docstrings now say the
  timeout is in whole seconds.

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