forked from ztwo/Auto_Analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartAppium.py
More file actions
66 lines (54 loc) · 1.62 KB
/
StartAppium.py
File metadata and controls
66 lines (54 loc) · 1.62 KB
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
# -*- coding: utf-8 -*-
__author__ = 'joko'
"""
@author:joko
@time: 16/11/8 下午2:52
"""
import lib.Utils as U
import random
import platform
class Sp:
def __init__(self, device):
self.device = device
def __start_driver(self, aport, bpport):
"""
清理logcat与appium所有进程
:return:
"""
if platform.system() == 'Windows':
# 在win10启动appium有bug,暂时处理方案
import subprocess
subprocess.Popen("appium -p %s -bp %s -U %s" %
(aport, bpport, self.device), shell=True)
else:
appium = U.cmd("appium -p %s -bp %s -U %s" %
(aport, bpport, self.device)) # 启动appium
while True:
appium_line = appium.stdout.readline().strip()
U.Logging.debug(appium_line)
U.sleep(1)
if 'listener started' in appium_line or 'Error: listen' in appium_line:
break
def start_appium(self):
"""
启动appium
p:appium port
bp:bootstrap port
:return: 返回appium端口参数
"""
aport = random.randint(4700, 4900)
bpport = random.randint(4700, 4900)
self.__start_driver(aport, bpport)
U.Logging.debug(
'start appium :p %s bp %s device:%s' %
(aport, bpport, self.device))
U.sleep(10)
return aport
def main(self):
"""
:return: 启动appium
"""
return self.start_appium()
if __name__ == '__main__':
s = Sp('0530dc6a')
s.main()