-
Notifications
You must be signed in to change notification settings - Fork 504
/
appium_utils.py
77 lines (66 loc) · 1.63 KB
/
appium_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
# encoding: utf-8
"""
@version: v1.0
@author: xag
@license: Apache Licence
@contact: [email protected]
@site: http://www.xingag.top
@software: PyCharm
@file: appium_utils.py
@time: 2020-03-14 14:41
@description:来源:公众号【AirPython】,欢迎关注
"""
from appium.webdriver.webdriver import WebDriver
def getSize(driver: WebDriver):
x = driver.get_window_size()['width'] # width为x坐标
y = driver.get_window_size()['height'] # height为y坐标
return (x, y)
def swipe_up(driver: WebDriver, peroid):
"""
向上滑动
:param driver:
:param peroid:
:return:
"""
l = getSize(driver)
x1 = int(l[0] * 0.5)
y1 = int(l[1] * 0.75)
y2 = int(l[1] * 0.5)
driver.swipe(x1, y1, x1, y2, peroid)
def swipe_up_small(driver: WebDriver, peroid):
"""
向上滑动(小距离)
:param driver:
:param peroid:
:return:
"""
l = getSize(driver)
x1 = int(l[0] * 0.5)
y1 = int(l[1] * 0.7)
y2 = int(l[1] * 0.6)
driver.swipe(x1, y1, x1, y2, peroid)
def swipe_up_with_distance(driver: WebDriver, distance, peroid):
"""
向上滑动固定的距离
:param driver:
:param peroid:
:return:
"""
l = getSize(driver)
x1 = int(l[0] * 0.5)
y1 = int(l[1] * 0.9)
y2 = int(l[1] * 0.9 - distance)
driver.swipe(x1, y1, x1, y2, peroid)
def swipe_down(driver: WebDriver, peroid):
"""
向下滑动
:param driver:
:param peroid:
:return:
"""
l = getSize(driver)
x1 = int(l[0] * 0.5)
y1 = int(l[1] * 0.25)
y2 = int(l[1] * 0.75)
driver.swipe(x1, y1, x1, y2, peroid)