├── .gitignore ├── Android └── calculator.air │ ├── calculator.py │ └── com.google.android.calculator.apk ├── Cocos2dx └── test_blackjack.air │ ├── blackjack-release-signed.apk │ ├── log │ ├── 1517995445984.jpg │ ├── 1517995448303.jpg │ ├── 1517995448693.jpg │ ├── 1517995449030.jpg │ ├── 1518339492890.jpg │ ├── 1518339496263.jpg │ ├── 1518339496643.jpg │ ├── 1518339497079.jpg │ ├── 1518341072067.jpg │ ├── 1518341073789.jpg │ ├── 1518341074146.jpg │ ├── 1518341074452.jpg │ └── log.txt │ ├── test_blackjack.html │ ├── test_blackjack.py │ ├── tpl1499240443959.png │ ├── tpl1499240472304.png │ └── tpl1499240490986.png ├── README.md ├── Unity3D └── unitydemo.air │ ├── poco-demo.apk │ ├── tpl1522812811402.png │ └── unitydemo.py └── tutorial ├── tutorial_airtest.air ├── fish.py ├── tpl1530588210942.png ├── tpl1530588217451.png ├── tpl1530603698872.png ├── tpl1530603939766.png ├── tpl1530603956757.png ├── tpl1530604090919.png ├── tpl1534937087556.png └── tpl1534937094239.png ├── tutorial_poco.air └── fish2.py ├── tutorial_selenium.air ├── test_selenium.py ├── tpl1531983261533.png ├── tpl1531983270340.png ├── tpl1531983475240.png ├── tpl1531983482344.png ├── tpl1532503308722.png ├── tpl1533180370363.png ├── tpl1533180411951.png ├── tpl1534930299434.png └── tpl1534930307633.png └── tutorial_wechat.air ├── tpl1528888459176.png ├── tpl1528888543521.png ├── tpl1528888551098.png └── wechat_starbuck.air.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | 3 | # C extensions 4 | 5 | # Packages 6 | *.egg 7 | *.egg-info 8 | dist 9 | build 10 | eggs 11 | parts 12 | bin 13 | var 14 | sdist 15 | develop-eggs 16 | .installed.cfg 17 | lib 18 | lib64 19 | __pycache__ 20 | 21 | # Installer logs 22 | pip-log.txt 23 | 24 | # Unit test / coverage reports 25 | .coverage 26 | .tox 27 | nosetests.xml 28 | 29 | # Translations 30 | *.mo 31 | 32 | # Mr Developer 33 | .mr.developer.cfg 34 | .project 35 | .pydevproject 36 | tmp/ 37 | log/ 38 | *.log 39 | _site 40 | apps 41 | screen.jpg 42 | *.spec 43 | log.txt 44 | core/ios/certificate_config.py 45 | htmlcov/ 46 | cover/ 47 | 48 | .idea/ 49 | .DS_Store 50 | env/ 51 | screencapture.bmp 52 | log.html 53 | log.gif 54 | screen.png 55 | log.txt 56 | img_record 57 | 58 | #docs 59 | docs/_build 60 | docs/README.rst 61 | docs/demo.gif 62 | 63 | #pipenv 64 | Pipfile 65 | Pipfile.lock 66 | 67 | *.sublime-project 68 | *.sublime-workspace 69 | -------------------------------------------------------------------------------- /Android/calculator.air/calculator.py: -------------------------------------------------------------------------------- 1 | # -*- encoding=utf8 -*- 2 | __author__ = "gzliuxin" 3 | __title__ = "test script title" 4 | __desc__ = """this is a test script.""" 5 | 6 | # start your script here 7 | 8 | from poco.drivers.android.uiautomation import AndroidUiautomationPoco 9 | from airtest.core.api import * 10 | 11 | PKG = "com.google.android.calculator" 12 | if PKG not in device().list_app(): 13 | import os 14 | path = os.path.join(args.script, "com.google.android.calculator.apk") 15 | device().install_app(path) 16 | 17 | stop_app(PKG) 18 | start_app(PKG) 19 | 20 | poco = AndroidUiautomationPoco() 21 | 22 | # test (1+2)==3 23 | poco("com.google.android.calculator:id/digit_1").click() 24 | poco("com.google.android.calculator:id/op_add").click() 25 | poco("com.google.android.calculator:id/digit_2").click() 26 | poco("com.google.android.calculator:id/eq").click() 27 | result = poco("com.google.android.calculator:id/result").get_text() 28 | assert_equal(result, "3") 29 | 30 | ## test swipe 31 | poco("com.google.android.calculator:id/arrow").click() 32 | sleep(1.0) 33 | fun_log = poco("com.google.android.calculator:id/fun_log").exists() 34 | assert_equal(fun_log, True) 35 | poco("com.google.android.calculator:id/arrow").swipe([0.6884, 0.01]) 36 | sleep(1.0) 37 | 38 | ## touch all numbers for fun 39 | poco("com.google.android.calculator:id/clr").click() 40 | for btn in poco(nameMatches="com.google.android.calculator:id/digit_\d"): 41 | print(btn) 42 | btn.click() 43 | 44 | result2 = poco("com.google.android.calculator:id/formula").get_text() 45 | assert_equal(result2, "7894561230") 46 | -------------------------------------------------------------------------------- /Android/calculator.air/com.google.android.calculator.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Android/calculator.air/com.google.android.calculator.apk -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/blackjack-release-signed.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/blackjack-release-signed.apk -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/1517995445984.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/log/1517995445984.jpg -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/1517995448303.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/log/1517995448303.jpg -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/1517995448693.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/log/1517995448693.jpg -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/1517995449030.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/log/1517995449030.jpg -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/1518339492890.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/log/1518339492890.jpg -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/1518339496263.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/log/1518339496263.jpg -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/1518339496643.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/log/1518339496643.jpg -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/1518339497079.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/log/1518339497079.jpg -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/1518341072067.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/log/1518341072067.jpg -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/1518341073789.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/log/1518341073789.jpg -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/1518341074146.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/log/1518341074146.jpg -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/1518341074452.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/log/1518341074452.jpg -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/log/log.txt: -------------------------------------------------------------------------------- 1 | {"depth": 0, "tag": "main_script", "data": {"script": "d:\\dev\\airtest\\tests\\../playground/test_blackjack.air"}, "time": "2018-02-11 17:24:17"} 2 | {"depth": 1, "tag": "function", "data": {"time_used": 1.496000051498413, "args": ["org.cocos2d.blackjack"], "name": "stop_app", "ret": null, "kwargs": {}}, "time": "2018-02-11 17:24:20"} 3 | {"depth": 1, "tag": "function", "data": {"time_used": 4.8440001010894775, "args": [], "name": "wake", "ret": null, "kwargs": {}}, "time": "2018-02-11 17:24:25"} 4 | {"depth": 1, "tag": "function", "data": {"time_used": 1.369999885559082, "args": ["org.cocos2d.blackjack"], "name": "start_app", "ret": null, "kwargs": {}}, "time": "2018-02-11 17:24:26"} 5 | {"depth": 1, "tag": "function", "data": {"time_used": 2.0, "args": [2], "name": "sleep", "ret": null, "kwargs": {}}, "time": "2018-02-11 17:24:28"} 6 | {"depth": 2, "tag": "function", "data": {"name": "loop_find", "kwargs": {"timeout": 20}, "time_used": 3.450000047683716, "screen": "1518341072067.jpg", "args": [{"record_pos": [0.22, -0.165], "filepath": "d:\\dev\\airtest\\tests\\../playground/test_blackjack.air\\tpl1499240443959.png", "rgb": false, "filename": "tpl1499240443959.png", "target_pos": 5, "threshold": 0.6, "resolution": [2560, 1536]}], "cv": {"confidence": 0.983008086681366, "result": [1361, 243], "rectangle": [[1080, 156], [1080, 331], [1643, 331], [1643, 156]]}, "ret": [1361, 243]}, "time": "2018-02-11 17:24:32"} 7 | {"depth": 1, "tag": "function", "data": {"time_used": 3.9750001430511475, "args": [{"record_pos": [0.22, -0.165], "filepath": "d:\\dev\\airtest\\tests\\../playground/test_blackjack.air\\tpl1499240443959.png", "rgb": false, "filename": "tpl1499240443959.png", "target_pos": 5, "threshold": 0.6, "resolution": [2560, 1536]}], "name": "touch", "ret": null, "kwargs": {}}, "time": "2018-02-11 17:24:32"} 8 | {"depth": 2, "tag": "function", "data": {"name": "loop_find", "kwargs": {"threshold": 0.7, "timeout": 20}, "time_used": 1.195000171661377, "screen": "1518341073789.jpg", "args": [{"record_pos": [0.0, -0.094], "filepath": "d:\\dev\\airtest\\tests\\../playground/test_blackjack.air\\tpl1499240472304.png", "rgb": false, "filename": "tpl1499240472304.png", "target_pos": 5, "threshold": 0.6, "resolution": [2560, 1536]}], "cv": {"confidence": 0.9773708581924438, "result": [960, 371], "rectangle": [[867, 328], [867, 415], [1053, 415], [1053, 328]]}, "ret": [960, 371]}, "time": "2018-02-11 17:24:33"} 9 | {"depth": 1, "tag": "function", "data": {"time_used": 1.1970000267028809, "args": [{"record_pos": [0.0, -0.094], "filepath": "d:\\dev\\airtest\\tests\\../playground/test_blackjack.air\\tpl1499240472304.png", "rgb": false, "filename": "tpl1499240472304.png", "target_pos": 5, "threshold": 0.6, "resolution": [2560, 1536]}, "\u8bf7\u4e0b\u6ce8"], "name": "assert_exists", "ret": [960, 371], "kwargs": {}}, "time": "2018-02-11 17:24:33"} 10 | {"depth": 2, "tag": "function", "data": {"name": "loop_find", "kwargs": {"interval": 0.5, "intervalfunc": null, "timeout": 20}, "time_used": 0.3510000705718994, "screen": "1518341074146.jpg", "args": [{"record_pos": [-0.443, -0.273], "filepath": "d:\\dev\\airtest\\tests\\../playground/test_blackjack.air\\tpl1499240490986.png", "rgb": false, "filename": "tpl1499240490986.png", "target_pos": 5, "threshold": 0.6, "resolution": [2560, 1536]}], "cv": {"confidence": 0.9916412830352783, "result": [103, 48], "rectangle": [[45, 4], [45, 92], [161, 92], [161, 4]]}, "ret": [103, 48]}, "time": "2018-02-11 17:24:34"} 11 | {"depth": 1, "tag": "function", "data": {"time_used": 0.3529999256134033, "args": [{"record_pos": [-0.443, -0.273], "filepath": "d:\\dev\\airtest\\tests\\../playground/test_blackjack.air\\tpl1499240490986.png", "rgb": false, "filename": "tpl1499240490986.png", "target_pos": 5, "threshold": 0.6, "resolution": [2560, 1536]}], "name": "wait", "ret": [103, 48], "kwargs": {}}, "time": "2018-02-11 17:24:34"} 12 | {"depth": 1, "tag": "function", "data": {"name": "touch", "kwargs": {}, "time_used": 0.41499996185302734, "screen": "1518341074452.jpg", "args": [[103, 48]], "ret": null}, "time": "2018-02-11 17:24:34"} 13 | {"depth": 1, "tag": "function", "data": {"time_used": 2.0, "args": [2], "name": "sleep", "ret": null, "kwargs": {}}, "time": "2018-02-11 17:24:36"} 14 | {"depth": 1, "tag": "function", "data": {"time_used": 2.046999931335449, "args": ["org.cocos2d.blackjack"], "name": "stop_app", "ret": null, "kwargs": {}}, "time": "2018-02-11 17:24:38"} 15 | -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/test_blackjack.py: -------------------------------------------------------------------------------- 1 | #encoding=utf8 2 | 3 | __author__ = "刘欣" 4 | 5 | from airtest.core.api import * 6 | import os 7 | 8 | PWD = args.script 9 | PKG = "org.cocos2d.blackjack" 10 | APK = os.path.join(PWD, "blackjack-release-signed.apk") 11 | if PKG not in device().list_app(): 12 | install(APK) 13 | stop_app(PKG) 14 | wake() 15 | start_app(PKG) 16 | sleep(2) 17 | touch(Template(r"tpl1499240443959.png", record_pos=(0.22, -0.165), resolution=(2560, 1536))) 18 | 19 | assert_exists(Template(r"tpl1499240472304.png", record_pos=(0.0, -0.094), resolution=(2560, 1536)), "请下注") 20 | 21 | 22 | p = wait(Template(r"tpl1499240490986.png", record_pos=(-0.443, -0.273), resolution=(2560, 1536))) 23 | 24 | touch(p) 25 | sleep(2) 26 | stop_app(PKG) 27 | 28 | -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/tpl1499240443959.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/tpl1499240443959.png -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/tpl1499240472304.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/tpl1499240472304.png -------------------------------------------------------------------------------- /Cocos2dx/test_blackjack.air/tpl1499240490986.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Cocos2dx/test_blackjack.air/tpl1499240490986.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Example 2 | ======== 3 | Example test scenarios using Airtest & Poco, incluing: 4 | 5 | * Android native apps 6 | * Unity3D games 7 | * Cocos2dx games 8 | 9 | [Get Started from Airtest Project Homepage](http://airtest.netease.com/) -------------------------------------------------------------------------------- /Unity3D/unitydemo.air/poco-demo.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Unity3D/unitydemo.air/poco-demo.apk -------------------------------------------------------------------------------- /Unity3D/unitydemo.air/tpl1522812811402.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/Unity3D/unitydemo.air/tpl1522812811402.png -------------------------------------------------------------------------------- /Unity3D/unitydemo.air/unitydemo.py: -------------------------------------------------------------------------------- 1 | # -*- encoding=utf8 -*- 2 | __author__ = "liuxin" 3 | 4 | from airtest.core.api import * 5 | 6 | auto_setup(__file__) 7 | 8 | # install demo apk 9 | PKG = "com.NetEase.PocoDemo" 10 | if PKG not in device().list_app(): 11 | import os 12 | path = os.path.join(args.script, "poco-demo.apk") 13 | device().install_app(path) 14 | 15 | # restart app 16 | stop_app(PKG) 17 | start_app(PKG) 18 | wait(Template(r"tpl1522812811402.png", record_pos=(0.001, -0.084), resolution=(1920, 1080))) 19 | 20 | # init UnityPoco 21 | from poco.drivers.unity3d import UnityPoco 22 | poco = UnityPoco() 23 | 24 | poco(text="Start").click() 25 | poco(text="basic").click() 26 | 27 | # assert empty 28 | result = poco(type="Text", name="Text").get_text() 29 | assert_equal(bool(result), False) 30 | 31 | # input text 32 | poco(type="InputField").set_text("Hello World") 33 | sleep(1.0) 34 | 35 | # assert text 36 | result = poco(type="Text", name="Text").get_text() 37 | assert_equal(result, "Hello World") 38 | 39 | poco(text="Back").click() 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /tutorial/tutorial_airtest.air/fish.py: -------------------------------------------------------------------------------- 1 | # -*- encoding=utf8 -*- 2 | __author__ = "airtest" 3 | 4 | from airtest.core.api import * 5 | 6 | auto_setup(__file__) 7 | 8 | start_app("com.netease.dyll") # 传入包名,打开这个待测app 9 | 10 | sleep(10) 11 | 12 | wait(Template(r"tpl1530603956757.png", record_pos=(0.001, -0.023), resolution=(1920, 1080))) # 等待,直到游戏画面出现 13 | 14 | 15 | touch(Template(r"tpl1530588210942.png", record_pos=(-0.177, 0.167), resolution=(1920, 1080))) 16 | 17 | sleep(1) # 等待1秒,确保切换到了下一个场景画面 18 | 19 | # 把关卡选择画面滑动到最右边,直到看到鲨鱼图案才停下 20 | while not exists(Template(r"tpl1530603698872.png", record_pos=(0.374, -0.001), resolution=(1920, 1080))): 21 | swipe((959, 609), vector=[-0.1706, 0.0025]) 22 | 23 | touch(Template(r"tpl1530603939766.png", record_pos=(0.365, 0.102), resolution=(1920, 1080))) 24 | 25 | assert_exists(Template(r"tpl1530604090919.png", record_pos=(-0.385, -0.173), resolution=(1920, 1080)), "断言是否进入了第20关") 26 | 27 | snapshot(msg="当前画面截图.") 28 | -------------------------------------------------------------------------------- /tutorial/tutorial_airtest.air/tpl1530588210942.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_airtest.air/tpl1530588210942.png -------------------------------------------------------------------------------- /tutorial/tutorial_airtest.air/tpl1530588217451.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_airtest.air/tpl1530588217451.png -------------------------------------------------------------------------------- /tutorial/tutorial_airtest.air/tpl1530603698872.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_airtest.air/tpl1530603698872.png -------------------------------------------------------------------------------- /tutorial/tutorial_airtest.air/tpl1530603939766.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_airtest.air/tpl1530603939766.png -------------------------------------------------------------------------------- /tutorial/tutorial_airtest.air/tpl1530603956757.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_airtest.air/tpl1530603956757.png -------------------------------------------------------------------------------- /tutorial/tutorial_airtest.air/tpl1530604090919.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_airtest.air/tpl1530604090919.png -------------------------------------------------------------------------------- /tutorial/tutorial_airtest.air/tpl1534937087556.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_airtest.air/tpl1534937087556.png -------------------------------------------------------------------------------- /tutorial/tutorial_airtest.air/tpl1534937094239.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_airtest.air/tpl1534937094239.png -------------------------------------------------------------------------------- /tutorial/tutorial_poco.air/fish2.py: -------------------------------------------------------------------------------- 1 | # -*- encoding=utf8 -*- 2 | __author__ = "zhangqi2011" 3 | 4 | from airtest.core.api import * 5 | 6 | auto_setup(__file__) 7 | 8 | # 初始化Poco,重要! 9 | from poco.drivers.unity3d import UnityPoco 10 | poco = UnityPoco() 11 | 12 | money = int(poco("Money").child('Text').get_text()) 13 | 14 | cost = int(poco("2024").child("Upgrade").child("NonFullPanel").child("Cost").child("Number").get_text()) 15 | 16 | # 点击待测道具的升级按钮 17 | poco("2024").child("Upgrade").child("NonFullPanel").child("UpgradeBtn").click() 18 | 19 | current_money = int(poco("Money").child('Text').get_text()) 20 | 21 | assert_equal(money-cost, current_money, "成功扣除对应金币") 22 | poco(text="600") 23 | -------------------------------------------------------------------------------- /tutorial/tutorial_selenium.air/test_selenium.py: -------------------------------------------------------------------------------- 1 | # -*- encoding=utf8 -*- 2 | from airtest.core.api import * 3 | 4 | __author__ = "zxfn4514" 5 | 6 | from selenium import webdriver 7 | from selenium.webdriver.common.keys import Keys 8 | from airtest_selenium.proxy import WebChrome 9 | driver = WebChrome() 10 | driver.implicitly_wait(20) 11 | 12 | driver.get("https://github.com/AirtestProject") 13 | driver.find_element_by_xpath("//*[@id=\"js-pjax-container\"]/div/header/div/nav/a[2]").click() 14 | driver.find_element_by_xpath("//a[@data-hotkey='g b']").click() 15 | driver.airtest_touch(Template(r"tpl1534930299434.png", record_pos=(12.015, 2.275), resolution=(100, 100))) 16 | driver.assert_template(Template(r"tpl1534930307633.png", record_pos=(8.61, 2.925), resolution=(100, 100)), "Please fill in the test point.") 17 | 18 | -------------------------------------------------------------------------------- /tutorial/tutorial_selenium.air/tpl1531983261533.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_selenium.air/tpl1531983261533.png -------------------------------------------------------------------------------- /tutorial/tutorial_selenium.air/tpl1531983270340.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_selenium.air/tpl1531983270340.png -------------------------------------------------------------------------------- /tutorial/tutorial_selenium.air/tpl1531983475240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_selenium.air/tpl1531983475240.png -------------------------------------------------------------------------------- /tutorial/tutorial_selenium.air/tpl1531983482344.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_selenium.air/tpl1531983482344.png -------------------------------------------------------------------------------- /tutorial/tutorial_selenium.air/tpl1532503308722.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_selenium.air/tpl1532503308722.png -------------------------------------------------------------------------------- /tutorial/tutorial_selenium.air/tpl1533180370363.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_selenium.air/tpl1533180370363.png -------------------------------------------------------------------------------- /tutorial/tutorial_selenium.air/tpl1533180411951.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_selenium.air/tpl1533180411951.png -------------------------------------------------------------------------------- /tutorial/tutorial_selenium.air/tpl1534930299434.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_selenium.air/tpl1534930299434.png -------------------------------------------------------------------------------- /tutorial/tutorial_selenium.air/tpl1534930307633.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_selenium.air/tpl1534930307633.png -------------------------------------------------------------------------------- /tutorial/tutorial_wechat.air/tpl1528888459176.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_wechat.air/tpl1528888459176.png -------------------------------------------------------------------------------- /tutorial/tutorial_wechat.air/tpl1528888543521.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_wechat.air/tpl1528888543521.png -------------------------------------------------------------------------------- /tutorial/tutorial_wechat.air/tpl1528888551098.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AirtestProject/Example/834443e66010dd5c29de83560c5d56197379f36c/tutorial/tutorial_wechat.air/tpl1528888551098.png -------------------------------------------------------------------------------- /tutorial/tutorial_wechat.air/wechat_starbuck.air.py: -------------------------------------------------------------------------------- 1 | # -*- encoding=utf8 -*- 2 | __author__ = "suyuchen" 3 | 4 | from airtest.core.api import * 5 | 6 | from poco.drivers.ios import iosPoco 7 | auto_setup(__file__) 8 | #connect_device("ios:///http://10.254.51.239:8100") 9 | poco = iosPoco() 10 | poco("微信").click() 11 | 12 | touch(Template(r"tpl1528888459176.png", record_pos=(-0.372, -0.544), resolution=(750, 1334))) 13 | sleep(1) 14 | snapshot() 15 | while not poco("有你真好").exists(): 16 | poco.scroll(direction='vertical', percent=0.3, duration=1.0) 17 | 18 | sleep(1) 19 | poco("有你真好").click() 20 | sleep(1) 21 | poco("当季特饮").click() 22 | touch(Template(r"tpl1528888543521.png", record_pos=(-0.424, -0.221), resolution=(750, 1334))) 23 | touch(Template(r"tpl1528888551098.png", record_pos=(0.395, 0.237), resolution=(750, 1334))) 24 | poco("\r 购买\r").click() 25 | 26 | 27 | 28 | 29 | 30 | 31 | --------------------------------------------------------------------------------