zoukankan      html  css  js  c++  java
  • 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)
            
  • 相关阅读:
    Dapper使用
    EF5.X Code First表关联与延迟加载
    EF Code First 学习笔记:关系
    Entity Framework
    MVC3+EF4.1学习系列(五)----- EF查找导航属性的几种方式
    QML与C++混合编程
    如何将信号从javascript发射到qml
    qt quick中qml编程语言
    PyQt 5信号与槽的几种高级玩法
    静态编译OpenSSL并整合到Qt
  • 原文地址:https://www.cnblogs.com/hanzhao1987/p/5949121.html
Copyright © 2011-2022 走看看