- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
Latest commit
77 lines (64 loc) · 2 KB
/
Copy pathtest.py
File metadata and controls
77 lines (64 loc) · 2 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
fromarchimportactivity
fromarchimportconsts
fromarchimportdevice
fromarchimporthppium
fromarchimporttools
if__name__=='__main__':
device=device.Device({
"os_name": "Android",
"os_version": "4.4",
"ip": "192.168.1.53",
"port": 5555
})
activity=activity.Activity({
"package": "com.jamdeo.tv.vod",
"class": "com.hisense.base.MainActivity"
})
device.connect()
hppium=hppium.Hppium(device, activity)
hppium.start_driver()
try:
tools.sleep(3)
# widget = hppium.find_widget({
# "finder": consts.Finder.ID,
# "value": "com.jamdeo.tv.vod:id/test_list"
# })
#
# if widget.find():
# print("find test item list.")
# else:
# exit(0)
#
# # FIXME: 以下代码还无法正常工作
# widget = widget.find_child({
# "finder": consts.Finder.XPATH,
# "value": "//android.widget.TextView",
# # "index": 0
# })
widget=hppium.find_widget({
"finder": consts.Finder.XPATH_2,
# "value": "//android.widget.ListView/android.widget.TextView[contains(@text, '自动化测试')]",
"value": "//android.widget.ListView/android.widget.TextView",
"index": 1
})
ifwidget.find():
print("widget element parent type: %s"%widget._element._parent)
print("TextView text: %s"%widget.text())
# widget.send_keys("abcdefg")
widget.click()
else:
exit(0)
tools.sleep(3)
hppium.send_key(20)
tools.sleep(1)
hppium.send_key(20)
tools.sleep(1)
hppium.send_key(20)
tools.sleep(1)
hppium.send_key(19)
tools.sleep(3)
# except Exception:
# print("exception, fix it.")
finally:
hppium.stop_driver()
device.disconnect()