fix: Backwards compatible behaviour of swipe and scroll in action_helpers#744
fix: Backwards compatible behaviour of swipe and scroll in action_helpers#744KazuCocoa merged 5 commits intoappium:masterfrom
Conversation
- Fixed handling the duration argument in swipe() and scroll() helpers - Functionality is now the same as in older versions using TouchActions Fixes appium#743
- Fixed handling the duration argument in swipe() and scroll() helpers - Functionality is now the same as in older versions using TouchActions Fixes appium#743
- Fixed handling the duration argument in swipe() and scroll() helpers - Functionality is now the same as in older versions using TouchActions Fixes appium#743
|
thank you. I will take a look. |
|
we probably need to use timedelta type for duration, so then we never have to mix seconds and milliseconds |
- Fixed handling the duration argument in swipe() and scroll() helpers - Functionality is now the same as in older versions using TouchActions Fixes appium#743
|
I did not find the actual reason for the lint error in the CI logs, but I made a new commit that hopefully goes through. If this also fails the lint, then you need to tell me what to fix. Also, I made an important improvement to earlier version, where I did not realize that the duration given in the ActionBuilder affects all move-operations. So the first move to the point of pointer_down was also affected with the duration, which was of course wrong. It was not very intuitive to create a second ActionBuilder instance and assign the duration to only that one. But I tested it and the logs were indicating that it is the correct approach. |
KazuCocoa
left a comment
There was a problem hiding this comment.
Left a comment probably lint error, otherwise lgtm.
Actions are stored into actions in touch_input, so giving a new instance with the same touch_input helps keep actions.
- Fixed handling the duration argument in swipe() and scroll() helpers - Functionality is now the same as in older versions using TouchActions Fixes appium#743
|
Fixed the lint error in the latest commit. This is now ready from my point of view. |
| actions.w3c_actions.pointer_action.move_to(origin_el) | ||
| actions.w3c_actions.pointer_action.pointer_down() | ||
| # setup duration for second move only, assuming duration always has atleast default value | ||
| actions.w3c_actions = ActionBuilder(self, mouse=touch_input, duration=duration) |
There was a problem hiding this comment.
I don't understand the logic here - do we just reassign actions.w3c_actions property? what is then the point of having previous calls?
There was a problem hiding this comment.
Previous actions are in touch_input, so this one just updates duration.
actions.w3c_actions.pointer_action._duration = duration can be the alternative of the ActionBuilder(self, mouse=touch_input, duration=duration) to append actions in touch_input with the duration.
>>> touch_input
<selenium.webdriver.common.actions.pointer_input.PointerInput object at 0x108c750f0>
>>> touch_input.actions
[{'type': 'pointerDown', 'duration': 0, 'button': 0}, {'type': 'pointerDown', 'duration': 0, 'button': 0}, {'type': 'pointerUp', 'duration': 0, 'button': 0}]
There was a problem hiding this comment.
i think you can also call the create_xxx methods on touch_input itself, like touch_input.create_pointer_move(), right?
| actions.w3c_actions.pointer_action.move_to(origin_el) | ||
| actions.w3c_actions.pointer_action.pointer_down() | ||
| # setup duration for second move only, assuming duration always has atleast default value | ||
| actions.w3c_actions = ActionBuilder(self, mouse=touch_input, duration=duration) |
There was a problem hiding this comment.
Previous actions are in touch_input, so this one just updates duration.
actions.w3c_actions.pointer_action._duration = duration can be the alternative of the ActionBuilder(self, mouse=touch_input, duration=duration) to append actions in touch_input with the duration.
>>> touch_input
<selenium.webdriver.common.actions.pointer_input.PointerInput object at 0x108c750f0>
>>> touch_input.actions
[{'type': 'pointerDown', 'duration': 0, 'button': 0}, {'type': 'pointerDown', 'duration': 0, 'button': 0}, {'type': 'pointerUp', 'duration': 0, 'button': 0}]
|
for example this is how i draw a line using the python client: seems a bit less confusing. |
Fixes #743