-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.py
More file actions
52 lines (39 loc) · 1.47 KB
/
action.py
File metadata and controls
52 lines (39 loc) · 1.47 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
import os
import common
from datetime import datetime
from airtest.core.api import *
from airtest.core.api import G
from airtest.core.api import connect_device
from airtest.core.settings import Settings as ST
# def deviceConnect(uuid=None):
# if uuid == None:
# uuid = "1576457605007R5"
# device = connect_device("Android:///%s?cap_method=minicap&touch_method=adb" % (uuid))
# return device
def deviceConnect(uuid=None):
if uuid == None:
uuid = "1576457605007R5"
device = connect_device("Android://127.0.0.1:5037/%s?cap_method=minicap&touch_method=adb" % (uuid))
return device
def deviceRemoteConnect(ip=None):
if ip == None:
ip = "10.200.8.110:5555"
device = connect_device("Android:///%s?cap_method=minicap&touch_method=adb" % (ip))
return device
def phoneResolution():
phone_resolution = {}
phone_resolution["height"] = G.DEVICE.display_info["height"]
phone_resolution["width"] = G.DEVICE.display_info["width"]
return phone_resolution
def parseImage(path):
# path: .jpg file
# 同時套上airtest.core.api class Template
template = Template(path)
parseCV2 = template._imread()
return parseCV2
def phoneSnapShot(device, path):
nowTime = datetime.today().strftime("%Y%m%d_%H%M%S")
filename = os.path.join(path, r"screen_" + nowTime + ".jpg")
snapshot = device.snapshot(filename=filename, quality=ST.SNAPSHOT_QUALITY)
imageCV2 = parseImage(filename)
return imageCV2