Skip to content

fix(options): initialise _proxy so reading options.proxy works - #16

Draft
MattL1989 wants to merge 1 commit into
masterfrom
fix/options-proxy-attribute
Draft

MattL1989 wants to merge 1 commit into
masterfrom
fix/options-proxy-attribute

Conversation

@MattL1989

Copy link
Copy Markdown
Owner

Problem

AppiumOptions inherits the proxy property from Selenium's BaseOptions, which reads self._proxy. AppiumOptions.__init__ does not call BaseOptions.__init__, so _proxy is never set and reading the property fails:

UiAutomator2Options().proxy
# AttributeError: 'UiAutomator2Options' object has no attribute '_proxy'

Setting options.proxy = Proxy(...) already worked, because the setter creates the attribute. Reading it before setting it did not.

Fix

Set self._proxy = None in AppiumOptions.__init__, as BaseOptions.__init__ does.

Calling BaseOptions.__init__ instead is not safe. It also calls set_capability('pageLoadStrategy', 'normal'), which would add that capability to every Appium session. _proxy is the only attribute that BaseOptions' properties read and that AppiumOptions did not set. I left mobile_options alone: Appium never reads or sends it.

Tests

  • Added unit tests that check .proxy is None on new options, that setting a Selenium Proxy returns it from .proxy and sends it as the proxy capability, and that the default capabilities are unchanged (no pageLoadStrategy). Without the fix, the first test fails with AttributeError: 'AppiumOptions' object has no attribute '_proxy'.
  • ruff check, ruff format --check, mypy appium and the full unit test suite pass.

🤖 Generated with Claude Code

AppiumOptions.__init__ deliberately does not call BaseOptions.__init__,
because Selenium's version also sets pageLoadStrategy to normal, which
would add that capability to every Appium session. It only set up
_caps and _ignore_local_proxy, so the inherited proxy property, which
reads self._proxy, raised:

    >>> UiAutomator2Options().proxy
    AttributeError: 'UiAutomator2Options' object has no attribute '_proxy'

Initialise _proxy to None, as BaseOptions does. Setting a Selenium
Proxy already worked and still writes the proxy capability; the
default capabilities are unchanged.

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