运行程序问题:
解决办法:
手机系统版本较低导致,我是V4.2.2,在android 4.3 系统上运行正常
代码如下:
#coding=utf-8 ''' 作者:xxx 功能:测试计算器基本功能 注意事项:需要android 4.3以上系统 ''' from appium import webdriver import time #PATH = lambda p: os.path.abspath(os.path.join(os.path.dirname(__file__), p)) desired_caps={} desired_caps['platformName']='Android' desired_caps['platformVersion']='4.3' desired_caps['deviceName']='4d005eebb070606f' #desired_caps['deviceName']='MBIB8LOJL7MJ7L7H' desired_caps['appPackage'] = 'com.youba.calculate' desired_caps['appActivity'] = '.MainActivity' #原生的需要加. desired_caps['browserName'] = '' driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) print "成功打开app!" time.sleep(1) driver.find_element_by_id("com.youba.calculate:id/btn_ac").click() driver.find_element_by_name("2").click() driver.find_element_by_name("×").click() driver.find_element_by_name("5").click() driver.find_element_by_name("=").click() text=driver.find_element_by_id("com.youba.calculate:id/et_echo").text if text==5*2: print "测试通过" driver.quit()