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

feat: support w3c actions and velocity swipe #160

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Linloir
Copy link

@Linloir Linloir commented Nov 18, 2024

Description

Since the facebookarchive/WebDriverAgent has been archived and the current maintained version is the Appium fork, there has been an increasing demand to utilize the new endpoints introduced in the Appium fork. Notably, the /actions endpoint is now being used for complex touch operations.

In response to this demand, I have made some minor adaptations to support these endpoints, specifically implementing support for /actions and /wda/pressAndDragWithVelocity.

Changes

  • Add relevant Classes for W3CActions
  • Support /actions endpoint
  • Support /wda/pressAndDragWithVelocity endpoint

Copy link
Member

@codeskyblue codeskyblue left a comment

Choose a reason for hiding this comment

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

need a little update

wda/__init__.py Outdated Show resolved Hide resolved
wda/__init__.py Outdated Show resolved Hide resolved
wda/w3c_actions.py Outdated Show resolved Hide resolved
@codeskyblue codeskyblue self-assigned this Nov 20, 2024
@Linloir
Copy link
Author

Linloir commented Nov 21, 2024

Also documented W3CActions and its relevant classes

@Linloir Linloir requested a review from codeskyblue November 21, 2024 02:45
@Linloir
Copy link
Author

Linloir commented Nov 21, 2024

Added support for /wda/touch/multi/perform endpoint for wda under v7.0.0

@codeskyblue
Copy link
Member

今天早上review了一下,在想是否真的需要这么多的类(TouchTap, TouchLongPress,TouchPress,TouchMovement,FingerMovement)
这些类做了什么呢, with_xy, with_origin,部分类还有with_pressure 都是用来初始化类的成员变量的,而其他的方法并没有,既然如此去掉这些类是否可行呢。

我构思了一下,下面的方法是否可行呢。去掉这些类,直接把值传过去。功能效果一样,代码确更少了。

FingerAction().move(x, y).down.pause(0.1).up()
TouchActions().press(x, y, pressure=1).pause(.1).up() # 补充疑问,为什这里是.. Actions,而上面是..Action

@unlimitedcodeG
Copy link

need a little update

@unlimitedcodeG
Copy link

今天早上review了一下,在想是否真的需要这么多的类(TouchTap, TouchLongPress,TouchPress,TouchMovement,FingerMovement) 这些类做了什么呢, with_xy, with_origin,部分类还有with_pressure 都是用来初始化类的成员变量的,而其他的方法并没有,既然如此去掉这些类是否可行呢。

我构思了一下,下面的方法是否可行呢。去掉这些类,直接把值传过去。功能效果一样,代码确更少了。

FingerAction().move(x, y).down.pause(0.1).up()
TouchActions().press(x, y, pressure=1).pause(.1).up() # 补充疑问,为什这里是.. Actions,而上面是..Action

不愧是蓝哥, 这么优雅

@Linloir
Copy link
Author

Linloir commented Nov 24, 2024

今天早上review了一下,在想是否真的需要这么多的类(TouchTap, TouchLongPress,TouchPress,TouchMovement,FingerMovement)

这些类做了什么呢, with_xy, with_origin,部分类还有with_pressure 都是用来初始化类的成员变量的,而其他的方法并没有,既然如此去掉这些类是否可行呢。

我构思了一下,下面的方法是否可行呢。去掉这些类,直接把值传过去。功能效果一样,代码确更少了。

FingerAction().move(x, y).down.pause(0.1).up()

TouchActions().press(x, y, pressure=1).pause(.1).up() # 补充疑问,为什这里是.. Actions,而上面是..Action

确实在类的实现上面是有些冗余和重复了,下周 update 下

另,TouchActions 其实是为了对齐 W3CActions 的命名,不过 W3CActions 是多个 Actions 的并集,TouchAction 应该只对应一个滑动操作,这里应该确实是和 FingerAction 对齐会更好一些(?)

@codeskyblue
Copy link
Member

今天早上review了一下,在想是否真的需要这么多的类(TouchTap, TouchLongPress,TouchPress,TouchMovement,FingerMovement)
这些类做了什么呢, with_xy, with_origin,部分类还有with_pressure 都是用来初始化类的成员变量的,而其他的方法并没有,既然如此去掉这些类是否可行呢。
我构思了一下,下面的方法是否可行呢。去掉这些类,直接把值传过去。功能效果一样,代码确更少了。

FingerAction().move(x, y).down.pause(0.1).up()

TouchActions().press(x, y, pressure=1).pause(.1).up() # 补充疑问,为什这里是.. Actions,而上面是..Action

确实在类的实现上面是有些冗余和重复了,下周 update 下

另,TouchActions 其实是为了对齐 W3CActions 的命名,不过 W3CActions 是多个 Actions 的并集,TouchAction 应该只对应一个滑动操作,这里应该确实是和 FingerAction 对齐会更好一些(?)

其实我们封装代码的最终目的是为了更方便的去使用,如果增加了更多的类,却没有可读性和易用性的提升,其实类的封装反而是个累赘。没有必要完全对其,毕竟最终追求的是方便。

Returns:
Self for method chaining
"""
if second < 0:
Copy link
Member

Choose a reason for hiding this comment

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

这段是有有必要,直接second<0抛出ValueError是否更好

def swipe_with_velocity(self, x1: Union[int, float], y1: Union[int, float], x2: Union[int, float], y2: Union[int, float],
press_duration: float, hold_duration: float, velocity: float):
"""
Press down and drag with velocity, appium forked version of wda only
Copy link
Member

Choose a reason for hiding this comment

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

最好注明一下appium wda开始支持的版本

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.

3 participants