我在使用当当网的 APP 做练习,它的首页元素导航栏是一个 TabWidget 控件,id 为 tabs。里面有四个 ImageView。具体见下图
现在通过 driver.find_elements_by_name("tabs") 来取值,代码如下
import os
import time
from selenium import webdriver
# Returns abs path relative to this file and not cwd
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
desired_caps = {}
desired_caps['device'] = 'Android'
desired_caps['browserName'] = ''
desired_caps['version'] = '4.3'
desired_caps['app'] = PATH('d:/android/dd_android_client5.0.0-10-18.apk')
desired_caps['app-package'] = 'com.dangdang.buy2'
desired_caps['app-activity'] = '.StartupActivity'
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
time.sleep(10)
imageviews = driver.find_elements_by_name("tabs")
print imageviews
imageviews[0].click()
driver.quit()
执行后输出结果为
appium 输出信息为: