APK 链接:https://pan.baidu.com/s/17oeTM1qA0QjPBqLh6pS0Yg 提取码:s9ru # coding:utf-8 from appium import webdriver import time,traceback desired_caps = {} desired_caps['platformName'] = 'Android' desired_caps['platformVersion'] = '4.4.4' desired_caps['deviceName'] = 'test' desired_caps['app'] = r'c:/Appium/toutiao.apk' desired_caps['appPackage'] = 'io.manong.developerdaily' desired_caps['appActivity'] ='io.toutiao.android.ui.activity.LaunchActivity' desired_caps['unicodeKeyboard'] = True desired_caps['resetKeyboard'] = True desired_caps['noReset'] = True desired_caps['newCommandTimeout'] = 6000 driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps) driver.implicitly_wait(15) try: driver.find_element_by_class_name("android.widget.ImageButton") time.sleep(5) xpath = '//*[@resource-id = "io.manong.developerdaily:id/tab_bar"]//android.widget.RelativeLayout[5]//android.widget.TextView' driver.find_element_by_xpath(xpath).click() # eles = driver.find_elements_by_xpath('//*[@resource_id="io.manong.developerdaily:id/tab_bar"]//android.widget.TextView') # for ele in eles: # print ele.text # eles[3].click() #python time.sleep(3) driver.find_element_by_id('io.manong.developerdaily:id/login_btn').click() time.sleep(2) driver.find_element_by_xpath('//*[@resource-id="io.manong.developerdaily:id/tab_layout"]//android.widget.RelativeLayout[2]//android.widget.TextView').click() ele = driver.find_element_by_id('io.manong.developerdaily:id/edt_phone') ele.set_value('13717617074') time.sleep(3) ele = driver.find_element_by_id('io.manong.developerdaily:id/edt_password') ele.set_value('mao112233') time.sleep(2) driver.find_element_by_id('io.manong.developerdaily:id/btn_login').click() except: print traceback.print_exc() input('****Press to quit..') driver.quit()
参考:https://www.cnblogs.com/crstyl/articles/7266341.html