-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtest_client.py
45 lines (31 loc) · 1.36 KB
/
test_client.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
# -*- coding: utf-8 -*-
import time
import pytest
# sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# pip install -e .
from hmdriver2._client import HmClient
from hmdriver2.proto import HypiumResponse
@pytest.fixture
def client():
client = HmClient("FMR0223C13000649")
client.start()
yield client
client.release()
def test_client_create(client):
resp = client.invoke("Driver.create") # {"result":"Driver#0"}
assert resp == HypiumResponse("Driver#0")
def test_client_invoke(client):
resp: HypiumResponse = client.invoke("Driver.getDisplaySize")
assert resp == HypiumResponse({"x": 1260, "y": 2720})
# client.hdc.start_app("com.kuaishou.hmapp", "EntryAbility")
client.hdc.start_app("com.samples.test.uitest", "EntryAbility")
resp = client.invoke("On.text", this="On#seed", args=["showToast"]) # {"result":"On#0"}
by = resp.result
resp = client.invoke("Driver.findComponent", this="Driver#0", args=[by]) # {"result":"Component#0"}
t1 = int(time.time())
resp = client.invoke("Driver.waitForComponent", this="Driver#0", args=[by, 2000]) # {"result":"Component#0"}
t2 = int(time.time())
print(f"take: {t2 - t1}")
component = resp.result
resp = client.invoke("Component.getText", this=component, args=[]) # {"result":"Component#0"}
assert resp.result == "showToast"