diff options
| author | JIAO <JIAO@DESKTOP-Q4S6VOM> | 2022-12-26 14:06:36 +0800 |
|---|---|---|
| committer | JIAO <JIAO@DESKTOP-Q4S6VOM> | 2022-12-26 14:06:36 +0800 |
| commit | 7e2071cb8a141adbe2f6b9123938398e5b4064c4 (patch) | |
| tree | e098510afc8abbe032397a9766566c1823dacd7a | |
| parent | ec84b0480f2fb4b54c80099e5bcb13d5be0faf13 (diff) | |
youtube,twitter,baidu_ios脚本提交
13 files changed, 813 insertions, 0 deletions
diff --git a/App_automation/air_test_auto/app/baidu/baidu_ios.py b/App_automation/air_test_auto/app/baidu/baidu_ios.py new file mode 100644 index 0000000..0660dda --- /dev/null +++ b/App_automation/air_test_auto/app/baidu/baidu_ios.py @@ -0,0 +1,274 @@ +# -*- encoding=utf8 -*- +__author__ = "JIAO" + +import os +import sys +rootDirectory = os.path.abspath(os.path.join(os.getcwd(), "../..")) +App_automation = r'{}{}'.format(rootDirectory, "App_automation") +sys.path.append(App_automation) +from airtest.core.api import * +import logging +logger = logging.getLogger("airtest") +logger.setLevel(logging.ERROR) +from air_test_auto.control import * +auto_setup(__file__,logdir=True) +init_device(platform="IOS",uuid=deviceid1) +from poco.drivers.ios import iosPoco +poco = iosPoco() +from airtest.report.report import * + + +def open(): + clearApp() + start_app("com.apple.Preferences") # 打开设置 + sleep(5) + swipe([570, 494], [578, 1098]) + sleep(5) + poco(name="搜索").click() + text("百度") + sleep(10) + if exists(Template(r"tpl1671508592051.png", record_pos=(-0.42, -0.778), resolution=(1170, 2532))): + print("app已安装,不需要重新安装") + stop_app("com.baidu.BaiduMobile") # 关闭app + start_app("com.baidu.BaiduMobile") # 打开app + sleep(5) + else: + start_app("com.apple.AppStore") # 打开app store + sleep(10) + poco(name="Search").click() + poco(name="SearchField").click() + text("百度") + sleep(5) + touch(Template(r"tpl1671508592051.png", record_pos=(-0.42, -0.778), resolution=(1170, 2532))) + sleep(10) + if poco(name="get").exists(): + poco(name="get").click() + sleep(20) + poco(name="安装").click() + sleep(2) + poco(name="SecureTextField").click() + sleep(2) + text("Test12345678") + sleep(2) + poco(name="登录").click() + sleep(180) + if poco(name="open").exists(): + print("app安装完成") + else: + print("app安装失败") + else: + poco(name="re-download").click() + sleep(180) + if poco(name="open").exists(): + print("app安装完成") + start_app("com.baidu.BaiduMobile") + sleep(10) + else: + print("app安装失败") + try: + snapshot(msg="baidu_open") + assert_equal(poco(name="我的").exists(), True, "baidu_open succeeded") + print('baidu_open succeeded') + print('The test case succeeded', flush=True) + return print('The test case succeeded') + except AssertionError: + print("baidu_open failed") + print("The test case faileded", flush=True) + return print('The test case faileded') + +def login(): + try: + stop_app("com.baidu.BaiduMobile") # 关闭app + start_app("com.baidu.BaiduMobile") # 打开app + sleep(10) + if poco(name="跳过").exists(): + poco(name="跳过").click() + if poco(name="同意").exists(): + poco(name="同意").click() + sleep(5) + poco(name="我的").click() + if poco(name="关闭").exists(): + poco(name="关闭").click() + if poco(name="同意").exists(): + poco(name="同意").click() + if poco(name="百度账号").exists(): + poco(name="百度账号").click() + sleep(10) + if poco(name="android.widget.EditText").exists(): + poco(name="android.widget.EditText").set_text(baidu_account) + touch(Template(r"tpl1661244773167.png", record_pos=(-0.261, 0.036), resolution=(720, 1280))) + sleep(5) + poco(name="下一步").click() + sleep(2) + poco(name="帐号密码登录").click() + touch(Template(r"tpl1661245110955.png", record_pos=(0.01, -0.101), resolution=(720, 1280))) + text(baidu_password) + if poco(name="登 录").exists(): + poco(name="登 录").click() + sleep(20) + if poco(name="请输入登录密码").exists(): + poco(name="请输入登录密码").click() + text("test123456") + touch(Template(r"tpl1661244773167.png", record_pos=(-0.261, 0.036), resolution=(720, 1280))) + sleep(2) + poco(name="登 录").click() + sleep(10) + try: + snapshot(msg="baidu_login") + assert_equal(poco(name="关注").exists(), True, "baidu_login succeeded") + print('baidu_login succeeded') + print('The test case succeeded', flush=True) + return print('The test case succeeded') + except AssertionError: + print("baidu_login failed") + print("The test case failed", flush=True) + return print('The test case failed') + finally: + a1 = r'{}{}'.format(report_dataDir, "/" + report_name) + rp = LogToHtml(__file__, export_dir=a1, lang='zh', plugins=["poco.utils.airtest.report"]) + rp.report(output_file=report_name + "_" + r"_test.html") + +def search(): + try: + stop_app("com.baidu.BaiduMobile") # 关闭app + start_app("com.baidu.BaiduMobile") # 打开app + sleep(10) + poco(name="SearchBox_test").click() + text("hello") + sleep(20) + try: + snapshot(msg="baidu_search") + if poco(text="全部").exists(): + assert_equal(poco(name="全部").exists(), True, "baidu_search succeeded") + else: + assert_equal(poco(name="综合").exists(), True, "baidu_search succeeded") + print('baidu_search succeeded') + print('The test case succeeded', flush=True) + stop_app("com.baidu.BaiduMobile") + return print('The test case succeeded') + except AssertionError: + print("baidu_search failed") + print("The test case failed", flush=True) + stop_app("com.baidu.BaiduMobile") + return print('The test case failed') + finally: + a1 = r'{}{}'.format(report_dataDir, "/" + report_name) + rp = LogToHtml(__file__, export_dir=a1, lang='zh', plugins=["poco.utils.airtest.report"]) + rp.report(output_file=report_name + "_" + r"_test.html") + +def video(): + try: + stop_app("com.baidu.BaiduMobile") # 关闭app + start_app("com.baidu.BaiduMobile") # 打开app + sleep(10) + if poco(name="视频").exists(): + poco(name="视频").click() + if exists(Template(r"tpl1664163908812.png", record_pos=(-0.209, 1.023), resolution=(1236, 2676))): + touch(Template(r"tpl1664163908812.png", record_pos=(-0.209, 1.023), resolution=(1236, 2676))) + if poco(name="关注").exists(): + poco(name="关注").click() + sleep(5) + if exists(Template(r"tpl1664329649888.png", record_pos=(-0.423, -0.943), resolution=(1236, 2676))): + touch(Template(r"tpl1664329649888.png", record_pos=(-0.423, -0.943), resolution=(1236, 2676))) + sleep(5) + if poco(name="上滑查看下条视频").exists(): + poco(name="上滑查看下条视频").click() + sleep(10) + if poco(name="搜索全网视频").exists(): + poco(name="搜索全网视频").click() + if exists(Template(r"tpl1664164478024.png", record_pos=(-0.425, -0.939), resolution=(1236, 2676))): + touch(Template(r"tpl1664164478024.png", record_pos=(-0.425, -0.939), resolution=(1236, 2676))) + if poco(name="bdp flow vlp topbar search").exists(): + poco(name="bdp flow vlp topbar search").click() + sleep(5) + text("hello") + sleep(20) + try: + snapshot(msg="baidu_video") + if poco(name="全部").exists(): + assert_equal(poco(name="全部").exists(), True, "baidu_video succeeded") + else: + assert_equal(poco(name="综合").exists(), True, "baidu_video succeeded") + print("baidu_video succeeded") + print("The test case succeeded", flush=True) + stop_app("com.baidu.BaiduMobile") + return print('The test case succeeded') + except AssertionError: + print("baidu_video failed") + print('The test case failed', flush=True) + stop_app("com.baidu.BaiduMobile") + return print('The test case failed') + finally: + a1 = r'{}{}'.format(report_dataDir, "/" + report_name) + rp = LogToHtml(__file__, export_dir=a1, lang='zh', plugins=["poco.utils.airtest.report"]) + rp.report(output_file=report_name + "_" + r".html") + +def frontPage(): + try: + stop_app("com.baidu.BaiduMobile") #关闭app + start_app("com.baidu.BaiduMobile") #打开app + sleep(10) + poco(name="热搜").click() + sleep(2) + for i in range(5): + swipe([502, 502], [559, 1073]) + sleep(10) + if poco(name="2").exists(): + poco(name="2").click() + sleep(120) + try: + snapshot(msg="baidu_frontPage") + if poco(name="全部").exists(): + assert_equal(poco(name="全部").exists(), True, "baidu_frontPage succeeded") + else: + assert_equal(poco(name="综合").exists(), True, "baidu_frontPage succeeded") + print('baidu_frontPage succeeded') + print('The test case succeeded', flush=True) + stop_app("com.baidu.BaiduMobile") + return print('The test case succeeded') + except AssertionError: + print("baidu_frontPage failed") + print("The test case failed", flush=True) + stop_app("com.baidu.BaiduMobile") + return print('The test case failed') + finally: + a1 = r'{}{}'.format(report_dataDir, "/" + report_name) + rp = LogToHtml(__file__, export_dir=a1, lang='zh', plugins=["poco.utils.airtest.report"]) + rp.report(output_file=report_name + "_" + r"_test.html") + +def close(): + stop_app("com.baidu.BaiduMobile") + +def clearApp(): + keyevent("HOME") + keyevent("HOME") + touch(Template(r"tpl1665468348186.png", record_pos=(-0.396, 0.657), resolution=(1170, 2532))) + touch(Template(r"tpl1665468418365.png", record_pos=(-0.001, 0.756), resolution=(1170, 2532))) + for i in range(10): + swipe([855, 1683], [852, 796]) + + + +if __name__ == '__main__': + baidu = sys.argv + for i in baidu: + if i == 'open': + open() + elif i == 'login': + login() + elif i == 'search': + search() + elif i == 'video': + video() + elif i == 'frontPage': + frontPage() + elif i == 'quit': + quit() + elif i == 'close': + close() + elif i == 'all': + open() + login() + search() + video() + frontPage()
\ No newline at end of file diff --git a/App_automation/air_test_auto/app/baidu/tpl1665468348186.png b/App_automation/air_test_auto/app/baidu/tpl1665468348186.png Binary files differnew file mode 100644 index 0000000..db2dbb4 --- /dev/null +++ b/App_automation/air_test_auto/app/baidu/tpl1665468348186.png diff --git a/App_automation/air_test_auto/app/baidu/tpl1665468418365.png b/App_automation/air_test_auto/app/baidu/tpl1665468418365.png Binary files differnew file mode 100644 index 0000000..47144db --- /dev/null +++ b/App_automation/air_test_auto/app/baidu/tpl1665468418365.png diff --git a/App_automation/air_test_auto/app/baidu/tpl1671508592051.png b/App_automation/air_test_auto/app/baidu/tpl1671508592051.png Binary files differnew file mode 100644 index 0000000..ec43367 --- /dev/null +++ b/App_automation/air_test_auto/app/baidu/tpl1671508592051.png diff --git a/App_automation/air_test_auto/app/twitter/tpl1665468348186.png b/App_automation/air_test_auto/app/twitter/tpl1665468348186.png Binary files differnew file mode 100644 index 0000000..db2dbb4 --- /dev/null +++ b/App_automation/air_test_auto/app/twitter/tpl1665468348186.png diff --git a/App_automation/air_test_auto/app/twitter/tpl1665468418365.png b/App_automation/air_test_auto/app/twitter/tpl1665468418365.png Binary files differnew file mode 100644 index 0000000..47144db --- /dev/null +++ b/App_automation/air_test_auto/app/twitter/tpl1665468418365.png diff --git a/App_automation/air_test_auto/app/twitter/tpl1669277033816.png b/App_automation/air_test_auto/app/twitter/tpl1669277033816.png Binary files differnew file mode 100644 index 0000000..4c9ba39 --- /dev/null +++ b/App_automation/air_test_auto/app/twitter/tpl1669277033816.png diff --git a/App_automation/air_test_auto/app/twitter/tpl1669365691667.png b/App_automation/air_test_auto/app/twitter/tpl1669365691667.png Binary files differnew file mode 100644 index 0000000..5b8667a --- /dev/null +++ b/App_automation/air_test_auto/app/twitter/tpl1669365691667.png diff --git a/App_automation/air_test_auto/app/twitter/twitter_ios.py b/App_automation/air_test_auto/app/twitter/twitter_ios.py new file mode 100644 index 0000000..f434091 --- /dev/null +++ b/App_automation/air_test_auto/app/twitter/twitter_ios.py @@ -0,0 +1,311 @@ +# -*- encoding=utf8 -*- +__author__ = "app" + +import os +import sys +rootDirectory = os.path.abspath(os.path.join(os.getcwd(), "../..")) +App_automation = r'{}{}'.format(rootDirectory, "App_automation") +sys.path.append(App_automation) +from airtest.core.api import * +import logging +logger = logging.getLogger("airtest") +logger.setLevel(logging.ERROR) +from air_test_auto.control import * +auto_setup(__file__,logdir=True) +init_device(platform="IOS",uuid=deviceid1) +from poco.drivers.ios import iosPoco +poco = iosPoco() +from airtest.report.report import * + + +def open(): + clearApp() + start_app("com.apple.Preferences") # 打开设置 + sleep(5) + swipe([570, 494], [578, 1098]) + sleep(5) + poco(name="搜索").click() + text("twitter") + sleep(10) + if exists(Template(r"tpl1669277033816.png", record_pos=(-0.417, -0.775), resolution=(1170, 2532))): + print("app已安装,不需要重新安装") + stop_app("com.atebits.Tweetie2") # 关闭app + start_app("com.atebits.Tweetie2") # 打开app + sleep(5) + else: + start_app("com.apple.AppStore") # 打开app store + sleep(20) + poco(name="Search").click() + poco(name="SearchField").click() + text("twitter") + sleep(10) + touch(Template(r"tpl1669277033816.png", record_pos=(-0.417, -0.775), resolution=(1170, 2532))) + sleep(10) + if poco(name="get").exists(): + poco(name="get").click() + sleep(20) + poco(name="安装").click() + sleep(2) + poco(name="SecureTextField").click() + sleep(2) + text("Test12345678") + sleep(2) + poco(name="登录").click() + sleep(180) + if poco(name="open").exists(): + print("app安装完成") + else: + print("app安装失败") + else: + poco(name="re-download").click() + sleep(180) + if poco(name="open").exists(): + print("app安装完成") + start_app("com.atebits.Tweetie2") + sleep(10) + else: + print("app安装失败") + try: + snapshot(msg="twitter_open") + assert_equal(poco(label="主页 标签").exists(), True, "twitter_open succeeded") + print('twitter_open succeeded') + print('The test case succeeded', flush=True) + return print('The test case succeeded') + except AssertionError: + print("twitter_open failed") + print("The test case faileded", flush=True) + return print('The test case faileded') + +def login(): + try: + stop_app("com.atebits.Tweetie2") + start_app("com.atebits.Tweetie2") + sleep(10) + if poco(name="登录").exists(): + poco(name="登录").click() + sleep(5) + poco(name="手机号码、邮件地址或用户名").click() + sleep(2) + text(twitter_account_ios) + if poco(name="下一步").exists(): + poco(name="下一步").click() + poco(value="密码").click() + sleep(2) + text(twitter_password_ios) + sleep(10) + poco(name="登录").click() + sleep(10) + try: + snapshot(msg="twitter_login") + assert_equal(poco(label="主页 标签").exists(), True, "twitter_login succeeded") + print('twitter_logim succeeded') + print('The test case succeeded', flush=True) + return print('The test case succeeded') + except AssertionError: + print("twitter_login failed") + print("The test case failed", flush=True) + return print('The test case failed') + finally: + a1 = r'{}{}'.format(report_dataDir, "/" + report_name) + rp = LogToHtml(__file__, export_dir=a1, lang='zh', plugins=["poco.utils.airtest.report"]) + rp.report(output_file=report_name + "_" + r"_test.html") + +def sendMessage(): + try: + stop_app("com.atebits.Tweetie2") # 关闭app + start_app("com.atebits.Tweetie2") # 打开app + sleep(10) + poco(label="私信 标签").click() + sleep(2) + poco(name="重明").click() + sleep(2) + poco(label="开始写私信 撰写新私信").click() + poco(name="发送").click() + sleep(20) + poco(name="从照片库中选择").click() + sleep(5) + poco(name="PhotoGalleryCell4").click() + sleep(20) + poco(name="发送").click() + sleep(10) + try: + snapshot(msg="twitter_sendMessage") + assert_not_equal(poco(name="正在发送").exists(), True, "twitter_sendMessage succeeded") + print('twitter_sendMessage succeeded') + print("The test case succeeded", flush=True) + # stop_app("com.atebits.Tweetie2") + return print('The test case succeeded') + except AssertionError: + print("twitter_sendMessage failed") + print('The test case failed', flush=True) + # stop_app("com.atebits.Tweetie2") + return print('The test case failed') + finally: + a1 = r'{}{}'.format(report_dataDir, "/" + report_name) + rp = LogToHtml(__file__, export_dir=a1, lang='zh', plugins=["poco.utils.airtest.report"]) + rp.report(output_file=report_name + "_" + r".html") + +def sendDynamic(): + try: + stop_app("com.atebits.Tweetie2") + start_app("com.atebits.Tweetie2") # 打开app + sleep(10) + poco(name="Timelines_tab").click() + sleep(2) + poco(name="FabComposeButton").click() + sleep(2) + if poco(name="稍后再说").exists(): + poco(name="稍后再说").click() + sleep(2) + if poco(name="有什么新鲜事?").exists(): + poco(name="有什么新鲜事?").click() + sleep(10) + message = 'test' + str(time.strftime("%Y%m%d%H%M", time.localtime())) + text(message) + sleep(2) + poco(name="发推").click() + sleep(2) + try: + snapshot(msg="twitter_sendDynamic") + assert_exists(Template(r"tpl1669365691667.png", record_pos=(-0.208, -0.852), resolution=(1170, 2532)), "twitter_sendDynamic succeeded") + print('twitter_sendDynamic succeeded') + print("The test case succeeded", flush=True) + stop_app("com.atebits.Tweetie2") + return print('The test case succeeded') + except AssertionError: + print("twitter_sendDynamic failed") + print('The test case failed', flush=True) + stop_app("com.atebits.Tweetie2") + return print('The test case failed') + finally: + a1 = r'{}{}'.format(report_dataDir, "/" + report_name) + rp = LogToHtml(__file__, export_dir=a1, lang='zh', plugins=["poco.utils.airtest.report"]) + rp.report(output_file=report_name + "_" + r"_test.html") + +def search(): + try: + stop_app("com.atebits.Tweetie2") # 关闭app + start_app("com.atebits.Tweetie2") # 打开app + sleep(10) + poco(name="Moments_tab").click() + sleep(2) + poco(name="搜索 Twitter").click() + sleep(2) + text("china") + sleep(20) + try: + snapshot(msg="twitter_search") + assert_not_equal(poco(name="正在载入...").exists(), True, "twitter_search succeeded") + print('twitter_search succeeded') + print("The test case succeeded", flush=True) + # stop_app("com.atebits.Tweetie2") + return print('The test case succeeded') + except AssertionError: + print("twitter_search failed") + print('The test case failed', flush=True) + # stop_app("com.atebits.Tweetie2") + return print('The test case failed') + finally: + a1 = r'{}{}'.format(report_dataDir, "/" + report_name) + rp = LogToHtml(__file__, export_dir=a1, lang='zh', plugins=["poco.utils.airtest.report"]) + rp.report(output_file=report_name + "_" + r"_test.html") + +def close(): + stop_app("com.atebits.Tweetie2") + +def clearApp(): + keyevent("HOME") + keyevent("HOME") + touch(Template(r"tpl1665468348186.png", record_pos=(-0.396, 0.657), resolution=(1170, 2532))) + touch(Template(r"tpl1665468418365.png", record_pos=(-0.001, 0.756), resolution=(1170, 2532))) + for i in range(10): + swipe([855, 1683], [852, 796]) + + + +if __name__ == '__main__': + twitter = sys.argv + for i in twitter: + if i == 'open': + open() + elif i == 'login': + login() + elif i == 'sendMessage': + sendMessage() + elif i == 'sendDynamic': + sendDynamic() + elif i == 'search': + search() + elif i == 'quit': + quit() + elif i == 'close': + close() + elif i == 'all': + open() + login() + sendMessage() + sendDynamic() + search() + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/App_automation/air_test_auto/app/youtube/tpl1665468348186.png b/App_automation/air_test_auto/app/youtube/tpl1665468348186.png Binary files differnew file mode 100644 index 0000000..db2dbb4 --- /dev/null +++ b/App_automation/air_test_auto/app/youtube/tpl1665468348186.png diff --git a/App_automation/air_test_auto/app/youtube/tpl1665468418365.png b/App_automation/air_test_auto/app/youtube/tpl1665468418365.png Binary files differnew file mode 100644 index 0000000..47144db --- /dev/null +++ b/App_automation/air_test_auto/app/youtube/tpl1665468418365.png diff --git a/App_automation/air_test_auto/app/youtube/tpl1669605426424.png b/App_automation/air_test_auto/app/youtube/tpl1669605426424.png Binary files differnew file mode 100644 index 0000000..5a94753 --- /dev/null +++ b/App_automation/air_test_auto/app/youtube/tpl1669605426424.png diff --git a/App_automation/air_test_auto/app/youtube/youtube_ios.py b/App_automation/air_test_auto/app/youtube/youtube_ios.py new file mode 100644 index 0000000..fd01729 --- /dev/null +++ b/App_automation/air_test_auto/app/youtube/youtube_ios.py @@ -0,0 +1,228 @@ +# -*- encoding=utf8 -*- +__author__ = "app" + +import os +import sys +rootDirectory = os.path.abspath(os.path.join(os.getcwd(), "../..")) +App_automation = r'{}{}'.format(rootDirectory, "App_automation") +sys.path.append(App_automation) +from airtest.core.api import * +import logging +logger = logging.getLogger("airtest") +logger.setLevel(logging.ERROR) +from air_test_auto.control import * +auto_setup(__file__,logdir=True) +init_device(platform="IOS",uuid=deviceid1) +from poco.drivers.ios import iosPoco +poco = iosPoco() +from airtest.report.report import * + + +def open(): + clearApp() + start_app("com.apple.Preferences") # 打开设置 + sleep(5) + swipe([570, 494], [578, 1098]) + sleep(5) + poco(name="搜索").click() + text("youtube") + sleep(10) + if exists(Template(r"tpl1669605426424.png", record_pos=(-0.422, -0.775), resolution=(1170, 2532))): + print("app已安装,不需要重新安装") + stop_app("com.google.ios.youtube") # 关闭app + start_app("com.google.ios.youtube") # 打开app + sleep(5) + else: + start_app("com.apple.AppStore") # 打开app store + sleep(20) + poco(name="Search").click() + poco(name="SearchField").click() + text("youtube") + sleep(10) + touch(Template(r"tpl1669605426424.png", record_pos=(-0.422, -0.775), resolution=(1170, 2532))) + sleep(10) + if poco(name="get").exists(): + poco(name="get").click() + sleep(20) + poco(name="安装").click() + sleep(2) + poco(name="SecureTextField").click() + sleep(2) + text("Test12345678") + sleep(2) + poco(name="登录").click() + sleep(180) + if poco(name="open").exists(): + print("app安装完成") + else: + print("app安装失败") + else: + poco(name="re-download").click() + sleep(180) + if poco(name="open").exists(): + print("app安装完成") + start_app("com.google.ios.youtube") + sleep(10) + else: + print("app安装失败") + try: + snapshot(msg="youtube_open") + assert_equal(poco(name="id.ui.navigation.search.button").exists(), True, "youtube_open succeeded") + print('youtube_open succeeded') + print('The test case succeeded', flush=True) + return print('The test case succeeded') + except AssertionError: + print("youtube_open failed") + print("The test case faileded", flush=True) + return print('The test case faileded') + +def search(): + try: + stop_app("com.google.ios.youtube") # 关闭app + start_app("com.google.ios.youtube") # 打开app + sleep(10) + if poco(name="跳过试订").exists(): + poco(name="跳过试订").click() + poco(name="id.ui.pivotbar.FEwhat_to_watch.button").click() + poco(name="id.ui.navigation.search.button").click() + sleep(2) + text("hello") + sleep(20) + try: + snapshot(msg="youtube_sendMessage") + assert_equal(poco(name="Cell").exists(), True, "youtube_search succeeded") + print('youtube_sendMessage succeeded') + print("The test case succeeded", flush=True) + stop_app("com.google.ios.youtube") + return print('The test case succeeded') + except AssertionError: + print("youtube_sendMessage failed") + print('The test case failed', flush=True) + stop_app("com.google.ios.youtube") + return print('The test case failed') + finally: + a1 = r'{}{}'.format(report_dataDir, "/" + report_name) + rp = LogToHtml(__file__, export_dir=a1, lang='zh', plugins=["poco.utils.airtest.report"]) + rp.report(output_file=report_name + "_" + r"_test.html") + +def shorts(): + try: + stop_app("com.google.ios.youtube") # 关闭app + start_app("com.google.ios.youtube") # 打开app + sleep(10) + poco(name="id.ui.pivotbar.FEshorts.button").click() + for i in range(5): + swipe([563, 464], [535, 1051]) + sleep(20) + try: + snapshot(msg="youtube_shorts") + assert_equal(poco(name="eml.subscribe_button").exists(), True, "youtube_shorts succeeded") + print('youtube_shorts succeeded') + print('The test case succeeded', flush=True) + stop_app("com.google.ios.youtube") + return print('The test case succeeded') + except AssertionError: + print("youtube_shorts failed") + print("The test case failed", flush=True) + stop_app("com.google.ios.youtube") + return print('The test case failed') + finally: + a1 = r'{}{}'.format(report_dataDir, "/" + report_name) + rp = LogToHtml(__file__, export_dir=a1, lang='zh', plugins=["poco.utils.airtest.report"]) + rp.report(output_file=report_name + "_" + r"_test.html") + +def frontPage(): + try: + stop_app("com.google.ios.youtube") # 关闭app + start_app("com.google.ios.youtube") # 打开app + sleep(10) + poco(name="id.ui.pivotbar.FEwhat_to_watch.button").click() + if poco(name="音乐").exists(): + poco(name="音乐").click() + sleep(5) + for i in range(3): + swipe([574, 875], [574, 1353]) + sleep(20) + try: + snapshot(msg="youtube_frontPage_ ") + assert_equal(poco(name="eml.vwc").exists(), True, "youtube_frontPage succeeded") + print('youtube_frontPage succeeded') + print('The test case succeeded', flush=True) + stop_app("com.google.ios.youtube") + return print('The test case succeeded') + except AssertionError: + print("youtube_frontPage failed") + print("The test case failed", flush=True) + stop_app("com.google.ios.youtube") + return print('The test case failed') + finally: + a1 = r'{}{}'.format(report_dataDir, "/" + report_name) + rp = LogToHtml(__file__, export_dir=a1, lang='zh', plugins=["poco.utils.airtest.report"]) + rp.report(output_file=report_name + "_" + r"_test.html") + +def SubscriptionContent(): + try: + stop_app("com.google.ios.youtube") # 关闭app + start_app("com.google.ios.youtube") # 打开app + sleep(10) + poco(name="id.ui.pivotbar.FEsubscriptions.button").click() + sleep(2) + for i in range(3): + swipe([574, 875], [574, 1353]) + sleep(20) + try: + snapshot(msg="youtube_SubscriptionContent") + assert_equal(poco(name="全部").exists(), True, "youtube_SubscriptionContent succeeded") + print('youtube_sendDynamic succeeded') + print("The test case succeeded", flush=True) + stop_app("com.google.ios.youtube") + return print('The test case succeeded') + except AssertionError: + print("youtube_sendDynamic failed") + print('The test case failed', flush=True) + stop_app("com.google.ios.youtube") + return print('The test case failed') + finally: + a1 = r'{}{}'.format(report_dataDir, "/" + report_name) + rp = LogToHtml(__file__, export_dir=a1, lang='zh', plugins=["poco.utils.airtest.report"]) + rp.report(output_file=report_name + "_" + r"_test.html") + +def close(): + stop_app("com.google.ios.youtube") + +def clearApp(): + keyevent("HOME") + keyevent("HOME") + touch(Template(r"tpl1665468348186.png", record_pos=(-0.396, 0.657), resolution=(1170, 2532))) + touch(Template(r"tpl1665468418365.png", record_pos=(-0.001, 0.756), resolution=(1170, 2532))) + for i in range(10): + swipe([855, 1683], [852, 796]) + +if __name__ == '__main__': + youtube = sys.argv + for i in youtube: + if i == 'open': + open() + elif i == 'search': + search() + elif i == 'shorts': + shorts() + elif i == 'frontPage': + frontPage() + elif i == 'SubscriptionContent': + SubscriptionContent() + elif i == 'close': + close() + elif i == 'all': + open() + search() + shorts() + frontPage() + SubscriptionContent() + + + + + + + |
