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

如何实现长按并拖动 #21

Closed
NateRiverNaz opened this issue Mar 23, 2018 · 8 comments
Closed

如何实现长按并拖动 #21

NateRiverNaz opened this issue Mar 23, 2018 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@NateRiverNaz
Copy link

查看了api,发现只有swipe 和 pinch

是否可以实现swipe_press

@adolli
Copy link
Member

adolli commented Mar 26, 2018

目前还没有这种组合,下一个大版本会加上MotionEvent. 到时就可以自定义手势了

@NateRiverNaz
Copy link
Author

好的 谢谢!

@Meteorix Meteorix added the enhancement New feature or request label Mar 26, 2018
@adolli adolli reopened this Mar 26, 2018
@Meteorix
Copy link
Member

@NateRiverNaz 你好,目前版本已经提供了MotionEvent,可以自己拼装任意操作

https://github.com/AirtestProject/Airtest/blob/master/playground/android_motionevents.py

@sosocgx
Copy link

sosocgx commented Apr 19, 2018

@Meteorix
你好, 根据您的写了例子改了一下,变成简单的按住并拖拽指定位置的图标到指定位置的实验

from airtest.core.api import *
from airtest.core.android.minitouch import *
connect_device("Android:///")
swipe_event = [DownEvent((500, 500)), SleepEvent(1),MoveEvent((0, 0)),UpEvent(0)]
device().minitouch.perform(swipe_event)

我的问题是:
1.具体DownEvent, SleepEvent,MoveEvent 的相关API文档,我想要实现比如传入name,TextMatches 之类的.
2.哪些event可以组合成motionevent?
2.完成图标的按住并拖拽后,手机坐标还是处于图标位置调整的状态,需要按home键。这种需要触发系统事件的,应该怎么调用?

thanks in advanced!!

@Meteorix
Copy link
Member

  1. 暂时还没写MotionEvent的文档,直接看看代码把,很简单的。Poco与MotionEvent的集成可能要稍等 @adolli 会更新
  2. 同样,看看代码
    class MotionEvent(object):
  3. 直接 home(),这些主要的API可以看API文档

@adolli
Copy link
Member

adolli commented Apr 26, 2018

如果使用poco的话,可以用以下简单写法,实现将一个图标拖拽到另一个图标上面

telephone = poco(text='电话')
folder = poco(text='文件夹')
telephone.start_gesture().hold(1).to(folder).hold(1).up()  # 最后面的up别忘了,hold时长根据实际情况调节

@IcyW
Copy link

IcyW commented Apr 28, 2019

@Meteorix
同请问长按并拖动至指定位置的操作。
请问MotionEvent的文档写了吗~?

@yimelia
Copy link
Member

yimelia commented Apr 28, 2019

@IcyW
可以参考这个文档以及仓库里的playground里的相关代码:
http://airtest.netease.com/docs/cn/9_faq/3_api_faq.html#id15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants