- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAutoEnterRoom.py
More file actions
Latest commit
102 lines (92 loc) · 3.63 KB
/
Copy pathAutoEnterRoom.py
File metadata and controls
102 lines (92 loc) · 3.63 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# coding=utf-8
importtime
importos
classAutoEnterRoom:
def__init__(self):
self.waitTime=10
self.phoneType=1
self.enterRoomX=0
self.enterRoomY=0
self.quitRoomX=0
self.quitRoomY=0
self.isStudent=True
defstart(self):
dataSize=input("课程数据量是否很大?默认是(y/n) \n")
if (dataSize=="y") or (len(dataSize) ==0) :
print("当前课程数据量较大")
self.waitTime=10
elifdataSize=="n":
print("当前课程数据量较小")
self.waitTime=5
else:
print("输入错误")
return
testPhone=input("选择机型:1(华为M2平板),2(小米平板2),3(Nexus5),4(红米2A),5(红米),6(vivo)默认1 \n")
if (testPhone=="1") or (len(testPhone) ==0):
print("当前机型:华为M2")
self.enterRoomX=400
self.enterRoomY=500
self.quitRoomX=1300
self.quitRoomY=610
self.waitTime+=15
eliftestPhone=="2":
print("当前机型:小米平板2")
self.enterRoomX=400
self.enterRoomY=640
self.quitRoomX=1480
self.quitRoomY=820
self.waitTime+=3
eliftestPhone=="3":
print("当前机型:Nexus5")
self.enterRoomX=200
self.enterRoomY=900
self.quitRoomX=1200
self.quitRoomY=610
self.waitTime+=5
eliftestPhone=="4":
print("当前机型:红米2A")
self.enterRoomX=200
self.enterRoomY=600
self.quitRoomX=1000
self.quitRoomY=410
self.waitTime+=2
eliftestPhone=="5":
print("当前机型:红米")
self.enterRoomX=150
self.enterRoomY=600
self.quitRoomX=1000
self.quitRoomY=410
self.waitTime+=2
eliftestPhone=="6":
print("当前机型:vivo")
self.enterRoomX=150
self.enterRoomY=600
self.quitRoomX=1000
self.quitRoomY=410
self.waitTime+=2
else:
print("不存在该机型")
return
isStudent=input("是否测试学生端进入教室?默认是(y/n) \n")
if (isStudent=="y") or (len(isStudent) ==0):
self.isStudent=True
print("即将测试学生端")
elifisStudent=="n":
self.isStudent=False
print("即将测试旁听端")
else:
print("输入错误,默认设为学生端")
self.isStudent=True
print("开始自动化进出教室") #程序奔溃,代表发生闪退,比对闪退时间与第几次进教室相近;程序卡死,则比对AS里正常退出教室的时间与第几次进教室时间相近则为最终承受次数
num=1
whileTrue:
timeStr=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
print("时间:",timeStr," 第 ",str(num)," 次进入教室")
num+=1
os.system("adb shell input tap "+str(self.enterRoomX) +" "+str(self.enterRoomY)) #进入教室
time.sleep(self.waitTime) #进教室休眠时间
os.system("adb shell input keyevent 4")
time.sleep(1)
os.system("adb shell input tap "+str(self.quitRoomX) +" "+str(self.quitRoomY)) #退出教室确认
time.sleep(4)
AutoEnterRoom().start()