Appium常用API(一)

Appium作为当下一款移动应用的自动化测试工具,对于测试来说重要性不言可寓,废话不多说,下面总结下它常用的API:

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

2.scroll
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
  - destinationE1- the element to scroll to
  Usage:
  driver.scroll(el1, el2)

3.drag_and_drop
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
  - destinationE1- the element to drag to
  Usage:

  driver.drag_and_drop(el1,el2)

4.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([(x,y),(x1,y1)],500)

5.swipe
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(x1,y1,x2,y2,500)
7.launch _app

launch_app(self):
  Start on the device the application specified in the desired capabilities.
  启动app
  Usage:
  driver.launch_app()

8.click

click(self):

  Clicks the element.

     点击元素

  Usage:

  element.click()

9.size

size(self):
  The size of the element.
  获取元素 的大小和高宽
  new_size["height"] = size["height"]
  new_size["width"] = size["width"]
  Usage:

  driver.element.size

10.location

location(self):
  The location of the element in the renderable canvas.
  获取取元 素的坐标
  Usage:

  driver.element.location 

  driver.element.location.get('x')  ''返回element的x坐标, int 型''
  driver.element.location.get('y')  ''返回element的y坐标, int 型''

 

待续~
   

转载于:https://www.cnblogs.com/cnkemi/p/9169475.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值