Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BySelector.copy becomes erroneous due to shallow copy. #62

Open
TranquilRock opened this issue Dec 5, 2024 · 1 comment
Open

BySelector.copy becomes erroneous due to shallow copy. #62

TranquilRock opened this issue Dec 5, 2024 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@TranquilRock
Copy link
Contributor

LOC related

Reproduction:

import mock
from snippet_uiautomator import uidevice

ui_device = uidevice.UiDevice(ui=mock.MagicMock())

root = ui_device(res='root')
view_group = root.child(clazz='android.view.ViewGroup')
# view_group._selector.to_dict() ==
# {'res':'root', 'child': {'clazz' : 'android.view.ViewGroup'}}

for i in range(3):
  ith_desc = view_group.children[i]['contentDescriptions']
  ith = view_group.child(desc=ith_desc)  # This change the view_group._selector
  # view_group._selector.to_dict() == ith._selector.to_dict() ==
  # {'res':'root', 'child': {'clazz' : 'android.view.ViewGroup', 'child': {'desc': ''}}}

Should we change to BySelector(copy.deepcopy(**self._selector) instead of BySelector(**self._selector)?

@ko1in1u ko1in1u self-assigned this Dec 26, 2024
@ko1in1u ko1in1u added the bug Something isn't working label Dec 26, 2024
@ko1in1u ko1in1u added this to the 1.1.3 milestone Dec 26, 2024
@ko1in1u
Copy link
Collaborator

ko1in1u commented Dec 26, 2024

Good catch! Yes, we should deep copy the dict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants