zoukankan      html  css  js  c++  java
  • appium(屏幕滑动)

     1 class handleswipe():
     2     """
     3     屏幕滑动操作
     4     """
     5 
     6     def __init__(self, driver, function, num=None):
     7         self.driver = driver
     8         self.function = function
     9         self.num = num
    10 
    11     def get_size(self):
    12         x = self.driver.get_window_size()['width']
    13         y = self.driver.get_window_size()['height']
    14         return x, y
    15 
    16     def swipeLeft(self):
    17         """
    18         向左滑动
    19         :return:
    20         """
    21         a = self.get_size()
    22         x1 = int(a[0] * 0.75)
    23         y1 = int(a[1] * 0.5)
    24         x2 = int(a[0] * 0.25)
    25         self.driver.swipe(x1, y1, x2, y1)
    26 
    27     def swipeReght(self):
    28         """
    29         向右滑动
    30         :return:
    31         """
    32         a = self.get_size()
    33         x1 = int(a[0] * 0.25)
    34         y1 = int(a[1] * 0.5)
    35         x2 = int(a[0] * 0.75)
    36         self.driver.swipe(x1, y1, x2, y1)
    37 
    38     def swipeUp(self):
    39         """
    40         向上滑动
    41         :return:
    42         """
    43         a = self.get_size()
    44         x1 = int(a[0] * 0.5)
    45         y1 = int(a[1] * 0.75)
    46         y2 = int(a[1] * 0.25)
    47         self.driver.swipe(x1, y1, x1, y2)
    48 
    49     def swipeDown(self):
    50         """
    51         向下滑动
    52         :return:
    53         """
    54         a = self.get_size()
    55         x1 = int(a[0] * 0.5)
    56         y1 = int(a[1] * 0.25)
    57         y2 = int(a[1] * 0.75)
    58         self.driver.swipe(x1, y1, x1, y2)
    59 
    60     def funcactivity(self):
    61         for i in range(self.num):
    62             handle = self.function
    63             if handle == 'swipeLeft':
    64                 self.swipeLeft()
    65             elif handle == 'swipeReght':
    66                 self.swipeReght()
    67             elif handle == 'swipeUp':
    68                 self.swipeUp()
    69             elif handle == 'swipeDown':
    70                 self.swipeDown()
    71             else:
    72                 break
    View Code
  • 相关阅读:
    数据库存储过程
    asp.net类中公共类DBHelp
    asp.net Cookie的用法实例
    使用SandCastle创建.Net帮助文档
    DotNetNuke(DNN)如何升级到DNN 4.9.3
    两个VS的文档工具
    SunBlogNuke.net logo设计
    自动化测试网站
    Debugging DLL Projects
    .NET 下自动生成UML图
  • 原文地址:https://www.cnblogs.com/97xiaolai/p/11833655.html
Copyright © 2011-2022 走看看