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
  • 相关阅读:
    SQL入门学习4-复杂查询
    SQL入门学习3-数据更新
    SQL入门学习2-聚合与排序
    SQL入门学习1-查询基础
    SQL入门学习0-数据库与SQL
    Exp9 20155218 Web安全基础实践
    20155218《网络对抗》Exp8 Web基础
    # 20155218 徐志瀚 EXP7 网络欺诈
    Exp6 20155218 信息搜集与漏洞扫描
    20155218《网络对抗》MSF基础应用
  • 原文地址:https://www.cnblogs.com/97xiaolai/p/11833655.html
Copyright © 2011-2022 走看看