c语言中文件名的全民,airtest一个例子:全民K歌,获取到第二个“A B C D E F G”并点击进入...

# -*- encoding=utf8 -*-

__author__ = "jiangjiahao"

from airtest.core.api import *

from poco.drivers.android.uiautomation import AndroidUiautomationPoco

poco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False)

auto_setup(__file__)

num = int(poco("com.tencent.karaoke:id/j_6").get_text())

print(num)

max_j = int(num%3)

max_i = int((num-max_j)/3)

# 获取第二个“A B C D E F G”

# 核心思想,i j 获取到对应的目标值

i = 0

j = 0

k = 0

for i in range(max_i+1):

if i != max_i:

for j in range(3):

#每个标题都是以这个开头

text_targer = poco("android.widget.LinearLayout").offspring("android:id/content").offspring(

"com.tencent.karaoke:id/b9c").child("com.tencent.karaoke:id/bya")[i].child(

"android.widget.LinearLayout")[j].offspring("com.tencent.karaoke:id/by8").get_text()

if str(text_targer.strip()) == "A B C D E F G":

k += 1

if k == 2:  #得到第二个判断

#每个视频进入的入口都是以这个开头

poco("android.widget.LinearLayout").offspring("com.tencent.karaoke:id/b9c").child(

"com.tencent.karaoke:id/bya")[i].child("android.widget.LinearLayout")[j].offspring(

"com.tencent.karaoke:id/by4").click()

else:

for j in range(max_j+1):

#每个标题都是以这个开头

text_targer = poco("android.widget.LinearLayout").offspring("android:id/content").offspring(

"com.tencent.karaoke:id/b9c").child("com.tencent.karaoke:id/bya")[i].child(

"android.widget.LinearLayout")[j].offspring("com.tencent.karaoke:id/by8").get_text()

if str(text_targer.strip()) == "A B C D E F G":

k += 1

if k == 2:  #得到第二个判断

#每个视频进入的入口都是以这个开头

poco("android.widget.LinearLayout").offspring("com.tencent.karaoke:id/b9c").child(

"com.tencent.karaoke:id/bya")[i].child("android.widget.LinearLayout")[j].offspring(

"com.tencent.karaoke:id/by4").click()