【appium】appium自动化入门之API(下)——两万字API长文,建议收藏

74个API大全
API太多了,我以为一天就能做出来,谁成想地鸽了三天(捂脸)
希望能对大家有所帮助嗷!!!
书接上文【appium】appium自动化入门之API(中)
环境搭建篇【appium】appium自动化入门之环境搭建(上)
下文链接【appium】appium自动化入门之元素篇

目录

Appium API

前言

Appium Python API 全集,可以查看所有的帮助文档

1.contexts (返回当前会话中的上下文,使用后可以识别 H5 页面的控件)

contexts(self): 
 Returns the contexts within the current session. 
 #返回当前会话中的上下文,使用后可以识别 H5 页面的控件
 :Usage: 
  driver.contexts 
用法 driver.contexts 

2.current_context (返回当前会话的当前上下文 )

current_context(self): 
 Returns the current context of the current session. 
 #返回当前会话的当前上下文 
 :Usage:
  driver.current_context 
用法 driver. current_context 

3. context (返回当前会话的当前上下文)

context(self): 
 Returns the current context of the current session. 
 #返回当前会话的当前上下文。 
 :Usage: 
  driver.context 
用法 driver. Context 

4.find_element_by_ios_uiautomation(通过 iOS uiautomation 查找元素)

find_element_by_ios_uiautomation(self, 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(通过 accessibility id 查找元素 )

find_element_by_accessibility_id(self, id): 
Finds an element by accessibility id. 
 #通过 accessibility id 查找元素 
 :Args:
  -d - a string corresponding to a recursive element search 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 (从元素 origin_el 滚动至元素 destination_el)

scroll(self, 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) 
用法 driver.scroll(el1,el2)

7.drag_and_drop(将元素 origin_el 拖到目标元素 destination_el )

 drag_and_drop(self, 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(self, positions, duration=None):
 Taps on an particular place with up to five fingers, holding for a certain time 
 #模拟手指点击(最多五个手指),可设置按住时间长度(毫秒) 
  :Args: - positions 
   - an array of tuples representing 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 (从 A 点滑动至 B 点,滑动时间为毫秒 )

swipe(self, 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 (按住 A 点后快速滑动至 B 点 )

 flick(self, 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(self, 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) 

12.zoom (在元素上执行放大操作)

zoom(self, 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: 
    driver.zoom(element) 
 用法 driver.zoom(element) 

13.reset (重置应用(类似删除应用数据) )

reset(self):
Resets the current application on the device.
重置应用(类似删除应用数据)
用法driver.reset()

14 hide_keyboard (隐藏键盘,iOS 使用 key_name 隐藏,安卓不使用参数 )

hide_keyboard(self, key_name=None, key=None, strategy=None):
 Hides the software keyboard on the device. In iOS, use `key_name` to press a particular key, or `strategy`. In Android
  • 25
    点赞
  • 239
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值