• Appium—python_ 安卓手机划屏幕操作


      开始的时候 不知道 python_unittest框架的命名规则,导致方法进不去,后来 改变方法名 能获取

    # conding=utf-8
    from appium import webdriver
    import time
    import unittest
    class Login(unittest.TestCase):
      desired_caps = {
                   'platformName':'Android',
                   'deviceName':'FA56GB105163',
                   'platformVersion':'5.0.2',
                   'appPackage':'com.zhonghong.www.qianjinsuo',
                   'appActivity':'com.zhonghong.www.qianjinsuo.main.activity.qjsMian.main.LoadingActivity',
                   'unicodeKeyboard':True,#使用unicodeKeyboard的编码方式来发送字符串 ,可以实现输入中文
                   'resetKeyboard':True #隐藏虚拟键盘,防止遮挡元素
                     }
      driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)
    #休眠15s等待程序启动
      time.sleep(5)
      print ("aaaaaaa")
    #获取页面长宽
      def test_a_getSize(self):
          x=self.driver.get_window_size()['width']
          y=self.driver.get_window_size()['height']
          return(x,y)
    #左向滑动,根据比例实现
      def test_b_swipeLeft(self):
            l=self.test_a_getSize()
            x1=int(l[0]*0.75)
            y1=int(l[1]*0.5)
            x2=int(l[0]*0.25)
            self.driver.swipe(x1,y1,x2,y1)
            #再滑动一次
            self.driver.swipe(x1,y1,x2,y1)
      
      def test_c_longin(self):
            self.driver.find_element_by_id("com.zhonghong.www.qianjinsuo:id/button_ok").click()
            time.sleep(2)
      """
    #向右滑动
        def test_swipeRight(self,t):
            l=self.getSize()
            x1=int(l[0]*0.25)
            y1=int(l[1]*0.5)
            x2=int(l[0]*0.75)
            self.driver.swipe(x1,y1,x2,y1,t)
    
            
    
    #向上滑动
        def test_swipeUp(self,t):
            l=self.getSize()
            x1=int(l[0]*0.5)
            y1=int(l[1]*0.75)
            y2=int(l[1]*0.25)
    
            self.driver.swipe(x1,y1,x1,y2,t)
    
    
    #向下滑动
    
        def test_swipeDown(self,t):
            l=self.getSize()
            x1=int(l[0]*0.5)
            y1=int(l[1]*0.25)
            y2=int(l[1]*0.75)
            
  • 相关阅读:
    Android随笔使用ViewPager实现简单地图片的左右滑动切换
    简单地Android中图片的三级缓存机制
    Java中怎么遍历map中value值 (转载)
    创建可执行的jar包
    写出优秀的java代码(转载)
    [JS脚本]ajax status 错误定义
    jsonlib 之jsonConfig详细使用(转载写的不错)
    Driver not found Error when sonar server is just not running
    使用Maven生成manifest
    ECMAScript 面向对象技术
  • 原文地址:https://www.cnblogs.com/hanzhao1987/p/5949121.html
Copyright © 2020-2023  润新知