zoukankan      html  css  js  c++  java
  • appium九宫格解锁错误提示:The coordinates provided to an interactions operation are invalid解决办法

    原文地址:http://blog.csdn.net/qqtMJK/article/details/77838814

    今天做自动化解锁9宫格,发现swipe不能满足需求,于是用TouchAction去实现手势滑动,这里先给出我写的代码:

    TouchAction(self.driver).press(x=299, y=744).wait(100)  
        .move_to(x=483, y=0).wait(100)  
        .move_to(x=-483, y=501).wait(100)  
        .move_to(x=483, y=0).wait(100).release().perform()

    根据UIAutomatorViewer抓到的坐标,我的坐标滑动需求是(299,744)—>(782,744)—>(299,1245)—>(782,1245)

    这个走势也就是一个“Z”字形的解锁路线。

    这里给出move_to的代码:

    def move_to(self, el=None, x=None, y=None):  
        """Move the pointer from the previous point to the element or point specified 
        """  
        self._add_action('moveTo', self._get_opts(el, x, y))  
      
        return self

    然后我执行我的代码之后还是报错:

    The coordinates provided to an interactions operation are invalid.

    提示说我的坐标无效,但是我确实填写的没有问题。然后我去翻看appium服务的log:

    从log看出,前面的坐标操作都是没有问题的,“Z”字可以正常画出来,但是最后touchUp的时候失败了,居然识别

    的是一个中间的偏移坐标值做touchUp,正好我这个偏移值还是负数,不在bounds里面,所以提示出错了。

    这里先不讨论原因,我改动代码之后就OK了,我贴出改动后的代码:

    TouchAction(self.driver).press(x=299, y=744).wait(100)  
        .move_to(x=483, y=0).wait(100)  
        .move_to(x=-483, y=501).wait(100)  
        .move_to(x=483, y=0).wait(100).release().wait(100).perform()

    标红的地方就是改动点,我仅仅是在release()后面加了一个wait就保证了touchUp正常执行

    就能正常在最后一个点touchUp。

    具体原因我不在此详细分析,感兴趣的可以去分析appium底层是怎么执行的

  • 相关阅读:
    Ansible 简单使用
    修改Elasticsearch的settings
    Nginx ssl证书部署
    配置 Haproxy 防范 DDOS 攻击
    Sort命令使用
    Haproxy ssl 配置方式
    MySQL连接线程kill利器之pt-kill
    percona-toolkit工具包的安装和使用
    Centos7 禁止firewalld并使用iptables 作默认防火墙以及忘记root密码的处理方法
    pt-query-digest查询日志分析工具
  • 原文地址:https://www.cnblogs.com/yrxns/p/8477626.html
Copyright © 2011-2022 走看看