APP自动化(java和python)——各种操作方法

更新时间:2023-06-15 23:20:42 阅读: 评论:0

APP⾃动化(java和python)——各种操作⽅法根据appium 1.4.13.1版本整理,1.5弃⽤了find by name 所以更新了下
Appium_Python_Api⽂档
contexts(lf):
Returns the contexts within the current ssion.
返回当前会话中的上下⽂,使⽤后可以识别H5页⾯的控件
:Usage:
⽤法 ts
2. current_context
current_context(lf):
Returns the current context of the current ssion.
返回当前会话的当前上下⽂
:Usage:
driver.current_context
⽤法driver. current_context
3. context
context(lf):
Returns the current context of the current ssion.
返回当前会话的当前上下⽂。
:Usage:
⽤法driver. Context
4. find_element_by_ios_uiautomation
find_element_by_ios_uiautomation(lf, uia_string):
Finds an element by uiautomation in iOS.
通过iOS uiautomation查找元素
:Args:
- uia_string - The element name in the iOS UIAutomation library
:Usage:
driver.find_element_by_ios_uiautomation('.elements()[1].cells()[2]')
⽤法dr. find_element_by_ios_uiautomation(‘elements’)
5. find_element_by_accessibility_id
find_element_by_accessibility_id(lf, id):
英语幼儿教育
Finds an element by accessibility id.
通过accessibility id查找元素
:Args:
- id - a string corresponding to a recursive element arch using the
Id/Name that the native Accessibility options utilize
:Usage:
driver.find_element_by_accessibility_id()
⽤法driver.find_element_by_accessibility_id(‘id’)
6.scroll
scroll(lf, origin_el, destination_el):
Scrolls from one element to another
从元素origin_el滚动⾄元素destination_el
:Args:
- originalEl - the element from which to being scrolling
- destinationEl - the element to scroll to
:Usage:
driver.scroll(el1, el2)
doto⽤法 driver.scroll(el1,el2)
7. drag_and_drop
drag_and_drop(lf, origin_el, destination_el):
Drag the origin element to the destination element
将元素origin_el拖到⽬标元素destination_el
:Args:
- originEl - the element to drag
- destinationEl - the element to drag to
⽤法 driver.drag_and_drop(el1,el2)
8.tap
tap(lf, positions, duration=None):
Taps on an particular place with up to five fingers, holding for a certain time 模拟⼿指点击(最多五个⼿指),可设置按住时间长度(毫秒)
:Args:
- positions - an array of tuples reprenting the x/y coordinates of
the fingers to tap. Length can be up to five.
- duration - (optional) length of time to tap, in ms
:Usage:
driver.tap([(100, 20), (100, 60), (100, 100)], 500)
⽤法 driver.tap([(x,y),(x1,y1)],500)
9. swipe
swipe(lf, start_x, start_y, end_x, end_y, duration=None): Swipe from one point to another point, for an optional duration.
从A点滑动⾄B点,滑动时间为毫秒
:Args:
- start_x - x-coordinate at which to start
- start_y - y-coordinate at which to start
- end_x - x-coordinate at which to stop
- end_y - y-coordinate at which to stop
- duration - (optional) time to take the swipe, in ms.
:Usage:
driver.swipe(100, 100, 100, 400)
⽤法 driver.swipe(x1,y1,x2,y2,500)
10.flick
flick(lf, start_x, start_y, end_x, end_y):
Flick from one point to another point.
按住A点后快速滑动⾄B点
:Args:
- start_x - x-coordinate at which to start
-
start_y - y-coordinate at which to start
- end_x - x-coordinate at which to stop
- end_y - y-coordinate at which to stop
:Usage:
driver.flick(100, 100, 100, 400)
⽤法 driver.flick(x1,y1,x2,y2)
11.pinch
pinch(lf, element=None, percent=200, steps=50):
Pinch on an element a certain amount
日语歌曲
在元素上执⾏模拟双指捏(缩⼩操作)
:Args:
-
element - the element to pinch
- percent - (optional) amount to pinch. Defaults to 200%
- steps - (optional) number of steps in the pinch action
:Usage:
driver.pinch(element)
⽤法 driver.pinch(element)
www immi gov au<
zoom(lf, element=None, percent=200, steps=50):
Zooms in on an element a certain amount
在元素上执⾏放⼤操作
:Args:
-
element - the element to zoom
- percent - (optional) amount to zoom. Defaults to 200%
- steps - (optional) number of steps in the zoom action
:Usage:
<(element)
⽤法 (element)
<
ret(lf):
Rets the current application on the device.
重置应⽤(类似删除应⽤数据)
⽤法 ()
14. hide_keyboard
hide_keyboard(lf, key_name=None, key=None, strategy=None):
Hides the software keyboard on the device. In iOS, u `key_name` to press a particular key, or `strategy`. In Android, no parameters are ud.
隐藏键盘,iOS使⽤key_name隐藏,安卓不使⽤参数
:Args:
- key_name - key to press
- strategy - strategy for closing the keyboard (e.g., `tapOutside`)
driver.hide_keyboard()
15. keyevent
keyevent(lf, keycode, metastate=None):
Sends a keycode to the device. Android only. Possible keycodes can be found in /reference/android/view/KeyEvent.html.发送按键码(安卓仅有),按键码可以上⽹址中找到
:Args:
- keycode - the keycode to be nt to the device
- metastate - meta information about the keycode being nt
⽤法 dr.keyevent(‘4’)
16. press_keycode
press_keycode(lf, keycode, metastate=None):
Sends a keycode to the device. Android only. Possible keycodes can be found in /reference/android/view/KeyEvent.html.发送按键码(安卓仅有),按键码可以上⽹址中找到
:Args:
- keycode - the keycode to be nt to the device
- metastate - meta information about the keycode being nt
⽤法 driver.press_ keycode(‘4’)
dr.keyevent(‘4’)与driver.press_ keycode(‘4’) 功能实现上⼀样的,都是按了返回键
17. long_press_keycode
long_press_keycode(lf, keycode, metastate=None):
Sends a long press of keycode to the device. Android only. Possible keycodes can be
found in /reference/android/view/KeyEvent.html.
发送⼀个长按的按键码(长按某键)
详细的按键代码见这⾥  /reference/android/view/KeyEvent.html.
:Args:
-
keycode - the keycode to be nt to the device
- metastate - meta information about the keycode being nt
⽤法 driver.long_press_keycode(4)  谢谢@t880216t童鞋反馈
18.current_activity
current_activity(lf):
Retrieves the current activity on the device.欧美一对一外教
获取当前的activity
⽤法 print(driver.current_activity)
19. wait_activity
wait_activity(lf, activity, timeout, interval=1):
Wait for an activity: block until target activity prents or time out.
This is an Android-only method.
等待指定的activity出现直到超时,interval为扫描间隔1秒
即每隔⼏秒获取⼀次当前的activity
返回的True 或 Fal
:Agrs:
- activity - target activity
- timeout - max wait time, in conds
- interval - sleep interval between retries, in conds
⽤法driver.wait_activity(‘.’,5,2)
20. background_app
background_app(lf, conds):
Puts the application in the background on the device for a certain duration.
后台运⾏app多少秒
:Args:
- conds - the duration for the application to remain in the background
⽤法 driver.background_app(5)  置后台5秒后再运⾏
21.is_app_installed
is_app_installed(lf, bundle_id):
Checks whether the application specified by `bundle_id` is installed on the device.
检查app是否有安装
顾思妤返回 True or Fal
:Args:
-
bundle_id - the id of the application to query
⽤法 driver.is_app_installed(“”)
obey22.install_app
install_app(lf, app_path):
Install the application found at `app_path` on the device.
安装app,app_path为安装包路径
:Args:
- app_path - the local or remote path to the application to install
⽤法 driver.install_app(app_path)
remove_app(lf, app_id):
Remove the specified application from the device.
删除app
:Args:
- app_id - the application id to be removed
⽤法 ve_app(“”)
24.launch_app
launch_app(lf):
Start on the device the application specified in the desired capabilities.
启动app
⽤法 driver.launch_app()
25.clo_app
clo_app(lf):
Stop the running application, specified in the desired capabilities, on the device.
关闭app
⽤法 driver.clo_app()
启动和关闭app运⾏好像会出错
26. start_activity
start_activity(lf, app_package, app_activity, **opts):
Opens an arbitrary activity during a test. If the activity belongs to
another application, that application is started and the activity is opened.
This is an Android-only method.
在测试过程中打开任意活动。如果活动属于另⼀个应⽤程序,该应⽤程序的启动和活动被打开。这是⼀个安卓的⽅法
:Args:
- app_package - The package containing the activity to start.
认字的方法有哪些- app_activity - The activity to start.
- app_wait_package - Begin automation after this package starts (optional).
- app_wait_activity - Begin automation after this activity starts (optional).
- intent_action - Intent to start (optional).
- intent_category - Intent category to start (optional).
- intent_flags - Flags to nd to the intent (optional).
- optional_intent_arguments - Optional arguments to the intent (optional).
- stop_app_on_ret - Should the app be stopped on ret (optional)?
⽤法 driver.start_activity(app_package, app_activity)
27.lock
lock(lf, conds):
Lock the device for a certain period of time. iOS only.
锁屏⼀段时间  iOS专有
:Args:
- the duration to lock the device, in conds
⽤法 driver.lock()
28.shake
shake(lf):
Shake the device.
摇⼀摇⼿机
⽤法 driver.shake()
29.open_notifications
open_notifications(lf):
Open notification shade in Android (API Level 18 and above)
打系统通知栏(仅⽀持API 18 以上的安卓系统)
⽤法 driver.open_notifications()
30work_connection
network_connection(lf):
Returns an integer bitmask specifying the network connection type.
Android only.
返回⽹络类型数值
Possible values are available through the enumeration `appium.webdriver.ConnectionType`
⽤法 driverwork_connection
31. t_network_connection
t_network_connection(lf, connectionType):
can you make it
Sets the network connection type. Android only.
Possible values:
Value (Alias)      | Data | Wifi | Airplane Mode
-------------------------------------------------
0 (None)          | 0    | 0    | 0
1 (Airplane Mode)  | 0    | 0    | 1
2 (Wifi only)      | 0    | 1    | 0
4 (Data only)      | 1    | 0    | 0
6 (All network on) | 1    | 1    | 0
The are available through the enumeration `appium.webdriver.ConnectionType`
设置⽹络类型
:Args:
- connectionType - a member of the enum appium.webdriver.ConnectionType
⽤法先加载from tiontype import ConnectionType合同英语
dr.t_network_connection(ConnectionType.WIFI_ONLY)
ConnectionType的类型有
NO_CONNECTION = 0
AIRPLANE_MODE = 1
WIFI_ONLY = 2
DATA_ONLY = 4
ALL_NETWORK_ON = 6
32. available_ime_engines
available_ime_engines(lf):
Get the available input methods for an Android device. Package and activity are returned (e.g., ['com.android.inputmethod.latin/.LatinIME'])    Android only.
返回安卓设备可⽤的输⼊法
⽤法print(driver.available_ime_engines)
33.is_ime_active
is_ime_active(lf):
Checks whether the device has IME rvice active. Returns True/Fal.
Android only.
检查设备是否有输⼊法服务活动。返回真/假。
安卓
⽤法 print(driver.is_ime_active())
34.activate_ime_engine
activate_ime_engine(lf, engine):
Activates the given IME engine on the device.
Android only.
激活安卓设备中的指定输⼊法,设备可⽤输⼊法可以从“available_ime_engines”获取
:Args:
- engine - the package and activity of the IME engine to activate (e.g.,
'com.android.inputmethod.latin/.LatinIME')
⽤法 driver.activate_ime_engine(“com.android.inputmethod.latin/.LatinIME”)
35.deactivate_ime_engine
deactivate_ime_engine(lf):
Deactivates the currently active IME engine on the device.
Android only.
关闭安卓设备当前的输⼊法
⽤法 driver.deactivate_ime_engine()
36.active_ime_engine
active_ime_engine(lf):
Returns the activity and package of the currently active IME engine (e.g.,
'com.android.inputmethod.latin/.LatinIME').

本文发布于:2023-06-15 23:20:42,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/146409.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:活动   元素   返回   按键   类似   设备
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图