Skip to content

feat: support w3c actions and velocity swipe#160

Open
Linloir wants to merge 7 commits into
openatx:masterfrom
Linloir:master
Open

feat: support w3c actions and velocity swipe#160
Linloir wants to merge 7 commits into
openatx:masterfrom
Linloir:master

Conversation

@Linloir

@Linloir Linloir commented Nov 18, 2024

Copy link
Copy Markdown

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

@codeskyblue codeskyblue left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

need a little update

Comment thread wda/__init__.py Outdated
Comment thread wda/__init__.py Outdated
Comment thread wda/w3c_actions.py Outdated
@codeskyblue codeskyblue self-assigned this Nov 20, 2024
@Linloir

Linloir commented Nov 21, 2024

Copy link
Copy Markdown
Author

Also documented W3CActions and its relevant classes

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

Linloir commented Nov 21, 2024

Copy link
Copy Markdown
Author

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

@codeskyblue

Copy link
Copy Markdown
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
Copy Markdown

need a little update

@unlimitedcodeG

Copy link
Copy Markdown

今天早上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

Linloir commented Nov 24, 2024

Copy link
Copy Markdown
Author

今天早上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
Copy Markdown
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 对齐会更好一些(?)

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

Comment thread wda/w3c_actions.py
Returns:
Self for method chaining
"""
if second < 0:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Comment thread wda/__init__.py
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
Copy Markdown
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