Skip to content

Conversation

@Zeros2619
Copy link
Contributor

支持以下写法,方便Selector的复用
icon_button = Selector(text="Icon")
d(icon_button).click()
d(selector=icon_button).click()
scroll_view = Selector(resourceId="abc")
d(scroll_view).scroll.to(selector=icon_button)

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 4, 2025

@codeskyblue codeskyblue requested a review from Copilot June 15, 2025 14:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for passing a Selector object as a parameter when creating a UiObject, which simplifies reuse of preconfigured selectors.

  • Adds handling of a "selector" keyword in the Selector constructor to clone underlying properties.
  • Updates the device call interface (call) to accept a positional parameter as a selector.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
uiautomator2/_selector.py Adds logic to initialize a Selector from another Selector instance.
uiautomator2/init.py Attempts to support passing a Selector as a positional argument.
Comments suppressed due to low confidence (1)

uiautomator2/init.py:457

  • The variable 'args' is referenced although it is not defined in the call method. Consider updating the function signature to include '*args' (i.e., def call(self, *args, **kwargs)) to properly support positional arguments.
if args and len(args) > 0:

@codeskyblue
Copy link
Member

看起来功能是没啥问题,就是感觉代码还可以更短一点

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.

2 participants