[Airtest]3.Coordinate Offset

2023-03-26  本文已影响0人  elf_fff

A. poco framework

0        1
 -------->
 |
 |   * (0.5,0.5)
\|/
1

the coordinate of element is like this. the left upper corner is (0,0), and the middle point is (0.5,0.5)

inside offset

poco('xxx').click() will click the center point(0.5,0.5) of the element. If you want to click other point:

poco('xxx').focus('center').click()  # the same as [0.5,0.5]
poco('xxx').focus([0.1,0.1]).click()
poco('xxx').focus([0.9,0.9]).click()

outside offset

if the coordinate value is less than 0 or more than 1, this means the point is outside the element range, which is permitted. You can use this way to locate the point close to the element.

poco('xxx').focus([-1, 3]).click()

B. Airtest framework

There's a similar function in Airtest framework.

  1  2  3
  *  *  *
  *  *5 *
  *  *  *9

target_pos is a parameter in touch() method, whose default value is 5, in the middle of the snapshot. If we want to click other point, we can set:

touch(Template('xxx.png'), target_pos=6, record_pos=(xx, xx), resolution=(yy,yy))
上一篇 下一篇

猜你喜欢

热点阅读