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
  - destinationE2- 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
  - destinationE2- 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

扫描二维码关注公众号,回复: 1560632 查看本文章

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

8.is _enabled

is_enabled(self):
  Returns whether the element is enabled.
  返回元素是否可用True of False
  Usage:

  element.is_enabled()

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 型''

待续~
   

猜你喜欢

转载自www.cnblogs.com/cnkemi/p/9169475.html