1. 用 UIautomator 定位到这样的元素
  2. 采用 content-desc 定位报错 AttributeError: 'WebDriver' object has no attribute 'findElementByAccessibilityId'
  3. 贴上我的代码 ```python #-- coding: UTF-8 -- import os import time import unittest from appium import webdriver global driver

class LoginAndroidTests(unittest.TestCase):
def setUp(self):
desired_caps={}
desired_caps['device'] = 'android'
desired_caps['platformName']='Android'
desired_caps['browserName']=''
desired_caps['platformVersion']='4.4.2'
desired_caps['deviceName']='MI NOTE LTE' # 这是测试机的型号
desired_caps['appPackage']='com.jinlufinancial.android.prometheus'
desired_caps['appActivity']='com.jinlufinancial.android.prometheus.StartMovieActivity'
self.driver=webdriver.Remote('http://localhost:4723/wd/hub,desired_caps')

def tearDown(self):
self.driver.quit()

def test_login(self):
time.sleep(10)
self.driver.findElementByAccessibilityId("百元玩电影 Link")

if name == 'main':
suite = unittest.TestLoader().loadTestsFromTestCase(LoginAndroidTests)
unittest.TextTestRunner(verbosity=2).run(suite)


↙↙↙阅读原文可查看相关链接,并与作者交流