|
from appium.webdriver.webdriver import WebDriver import csv from appium.webdriver.common.touch_action import TouchAction #定义一个字典类型,存放参数设置 caps={} caps['automationName']='UiAutomator2' caps['platformName']='Android' caps['platformVersion']='6.0' caps['deviceName']='192.168.165.101:5555' caps['appPackage']='com.android.calculator2' caps['appActivity']='.Calculator' #启动appium和模拟器 driver=WebDriver('http://127.0.0.1:4723/wd/hub',caps) #传入相关测试数据 #通过文件获取测试数据 file=open('test4.csv','r') rows=csv.reader(file) for row in rows: for i in range (0,7): print(row) print(row[7]) # print(row[0]) # print(row[1]) # print(row[2]) # print(row[3]) exresult = row[7] driver.find_element_by_id('com.android.calculator2:id/formula').send_keys(row) driver.find_element_by_id('com.android.calculator2:id/eq').click() result = driver.find_element_by_id('com.android.calculator2:id/formula').text if (int(result)==exresult): print("测试通过") else: print("测试失败") # clrele=driver.find_element_by_id('com.android.calculator2:id/clr') # TouchAction(driver).long_press(clrele).perform().wait(3000) # driver.find_element_by_id('com.android.calculator2:id/clr').click()
|
|