测试用例

image-1657938302082

# -*- encoding=utf8 -*-
__author__ = "shisuiyi"

from airtest.core.api import *

auto_setup(__file__)


from poco.drivers.android.uiautomation import AndroidUiautomationPoco

poco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False)
# 启动网易云app
start_app("com.netease.cloudmusic")

# 点击每日推荐
poco("com.netease.cloudmusic:id/ad4").click()
actual_day = poco("com.netease.cloudmusic:id/a63").get_text()
expect_dat = time.strftime('%d',time.localtime(time.time()))

assert_equal(actual_day, expect_dat, "判断当前日期是否是当天日期.")

assert_equal(poco(text = "播放全部").exists(), True)

# 点击电台
poco("com.netease.cloudmusic:id/adc").click()
sleep(1)
assert_exists(Template(r"tpl1657801721576.png", record_pos=(-0.394, -0.801), resolution=(1080, 1920)), "判断是否进入电台页面")

keyevent("BACK")
poco("com.netease.cloudmusic:id/ad7").click()
if poco(text = "推荐") and  poco(text = "精品").exists():
    print("出现二级导航栏")

    
keyevent("BACK")
poco("com.netease.cloudmusic:id/ad_").click()

if poco(text = "排行榜") .exists():
    print("出现排行榜")