-
Notifications
You must be signed in to change notification settings - Fork 142
/
test_u2.py
57 lines (42 loc) · 1.04 KB
/
test_u2.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
46
47
48
49
50
51
52
53
54
55
56
57
"""
uiautomator2 Library test demo
https://github.com/openatx/uiautomator2
"""
from poium.u2 import Page, XpathElement, Element
from poium.u2.driver import Android
class BingPage(Page):
news = XpathElement('//*[@text="News"]')
tabs = Element(text="Tabs")
class BingSearchPage(Page):
input = XpathElement('//*[@text="Search"]')
def test_bing_search():
# app
d = Android(package_name="com.microsoft.bing")
d.connect()
d.start_app()
# page
page = BingSearchPage(d.driver, d.package_name)
page.input.click()
page.input.set_text("poium")
page.sleep(1)
page.press(key="enter")
page.sleep(2)
# app
d.close_app()
def test_bing_app():
# app
d = Android(package_name="com.microsoft.bing")
d.connect()
d.start_app()
# page
page = BingPage(d.driver, d.package_name)
info = page.app_info()
page.news.click()
page.swipe_left(times=2)
page.sleep(2)
page.swipe_right()
page.sleep(2)
page.tabs.click()
page.sleep(2)
# app
d.close_app()