美文网首页
[Airtest]3.Coordinate Offset

[Airtest]3.Coordinate Offset

作者: elf_fff | 来源:发表于2023-03-26 14:41 被阅读0次

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

相关文章

网友评论

      本文标题:[Airtest]3.Coordinate Offset

      本文链接:https://www.haomeiwen.com/subject/vvwordtx.html