class WaitCase(object): def __init__(self, device_list, device_name, m_queue): self.device_list = device_list # 设备列表 self.device_name = device_name # 设备名称 self.device_info = device_list[device_name] # 设备信息表 database["m_queue"] = m_queue # 用于主进程和子进程通讯的消息队列 self.report = None # 初始化结果报告模块 self.xls = None # 初始化执行结果Excel文件模块 self.debug = None # 初始化debug日志模块 self.page = None # 初始化元素库模块 self.device_info_list = {} # 初始化设备信息 self.script_init_success = False # 脚本初始化结果标志位 database["case_location"] = 1 # 用例执行次数 self.row = 0 # Excel报告写入初始位置 self.sc = ShellCommand() # 实例化ShellCommand self.device_info["sc"] = self.sc database[device_name] = {} # 初始化设备数据库 try: self.create_debug() self.create_report() self.write_xls() self.select_page_element() self.check_appium() self.script_init_success = True except BaseException: self.debug.error(traceback.format_exc()) raise if self.script_init_success is True: self.run() else: raise ScriptInitError("Script Init Error!!! " "contain [create_debug(), create_log(), " "create_report(), write_xls(), check_appium()]") # 从元素库筛选对应APP元素库 def select_page_element(self): self.page = PageElement(self.device_info["platformName"]).get_page_element() self.device_info["page"] = self.page # 生成log格式运行结果 def create_report(self): self.report = check_report(self.device_info) self.device_info["report"] = self.report # 生成debug日志 def create_debug(self): self.debug = check_debug(self.device_info) self.device_info["debug"] = self.debug # 实例化Excel文件 def write_xls(self): self.xls = WriteXls(self.device_info) # 检查Appium服务是否启动 def check_appium(self): while True: try: self.sc.find_proc_and_pid_by_port(self.device_info["port"])[0] except IndexError: time.sleep(1) else: self.debug.info("Appium Sever Launch Success! %s" % time.strftime("%Y-%m-%d %X")) break # 开始执行用例 def run(self): # 填写设备信息日志 self.debug.info("*" * 30) self.debug.info(u"[APP_INF]deviceName:.....%s" % self.device_info["deviceName"]) self.debug.info(u"[APP_INF]UDID:...........%s" % self.device_info["udid"]) self.debug.info(u"[APP_INF]platformName:...%s" % self.device_info["platformName"]) self.debug.info(u"[APP_INF]platformVersion:%s" % self.device_info["platformVersion"]) # self.debug.info(u"[APP_INF]appPackage:.....%s" % self.device_info["desired_caps"]["appPackage"]) # self.debug.info(u"[APP_INF]appActivity:....%s" % self.device_info["desired_caps"]["appActivity"]) # self.debug.info(u"[APP_INF]waitActivity:...%s" % self.device_info["desired_caps"]["waitActivity"]) # self.debug.info(u"[APP_INF]bundleId:.......%s" % self.device_info["desired_caps"]["bundleId"]) # self.debug.info("******************************") for name, blank in [["appPackage", 5], ["appActivity", 4], ["waitActivity", 3], ["bundleId", 7]]: try: self.debug.info(u"[APP_INF]%s:%s%s" % (name, "." * blank, self.device_info["desired_caps"][name])) except KeyError: pass self.debug.info("*" * 30) # 执行用例 while True: self.debug.info("run times [%s]" % database["program_loop_time"]) # self.write_report(GNY201SCmp1) # 431, FUT_CMP_不同型号手机是否能正常添加设备 # self.write_report(GNY201SCrossTimer1) # 519, FUT_CROSSTIMER_普通定时、循环定时、延时定时交叉设置后定时执行 self.write_report(GNY201SCycleTimer1) # 470, FUT_CYCLETIMER_循环定时设置永久循环执行(1分钟开1分钟关) self.write_report(GNY201SCycleTimer2) # 471, FUT_CYCLETIMER_循环定时执行过程中手动切换设备状态 self.write_report(GNY201SCycleTimer3) # 482, FUT_CYCLETIMER_循环定时5次 self.write_report(GNY201SCycleTimer4) # 483, FUT_CYCLETIMER_循环定时1次 self.write_report(GNY201SDelayTimer1) # 469, FUT_DELAYTIMER_延时定时一分钟开关 # self.write_report(GNY201SDelayTimer2) # 468, FUT_DELAYTIMER_延迟定时一小时开 self.write_report(GNY201SDelayTimer3) # 466, FUT_DELAYTIMER_延迟定时5分钟开 # self.write_report(GNY201SDelayTimer4) # 465, FUT_DELAYTIMER_延时定时23小时59分钟开 self.write_report(GNY201SEem1) # 559, FUT_EEM_峰谷电价设置 self.write_report(GNY201SEem2) # 558, FUT_EEM_用电图表显示周期设置 # self.write_report(GNY201SEem3) # 551, FUT_EEM_电价设置验证(待定) # self.write_report(GNY201SEem4) # 550, FUT_EEM_实时功率显示及精度检查 # self.write_report(GNY201SLogin1) # 0000, 阿里智能APP账号登录 self.write_report(GNY201SNormalTimer1) # 517, FUT_NTIMER_冲突定时设置 self.write_report(GNY201SNormalTimer2) # 515, FUT_NTIMER_单次定时关 self.write_report(GNY201SNormalTimer3) # 513, FUT_NTIMER_单次定时开 self.write_report(GNY201SNormalTimer4) # 512, FUT_NTIMER_单日循环定时 # self.write_report(GNY201SNormalTimer5) # 510, FUT_NTIMER_定时时间早于当前时间的永不循环定时设置 # self.write_report(GNY201SNormalTimer6) # 508, FUT_NTIMER_隔天普通定时 self.write_report(GNY201SNormalTimer7) # 505, FUT_NTIMER_普通交叉定时 # self.write_report(GNY201SNormalTimer8) # 497, FUT_NTIMER_每日循环普通定时 self.write_report(GNY201SNormalTimer9) # 494, FUT_NTIMER_普通定时最大组数设定 self.write_report(GNY201SNormalTimer10) # 488, FUT_NTIMER_普通定时设置后手动改变设备状态 self.write_report(GNY201SNormalTimer11) # 417, FUT_NTIMER_普通定时循环信息检查 # self.write_report(GNY201SSmartLink1) # 498, FUT_SMTLNK_app能正常添加设备_按分类查找 self.write_report(GNY201SSwitch1) # 517, FUT_NTIMER_冲突定时设置 self.write_report(GNY201STimerFish1) # 442, FUT_MTIMER_FISH_鱼缸模式开启1分钟,关闭1分钟功能是否正常 # self.write_report(GNY201STimerFish2) # 441, FUT_MTIMER_FISH_鱼缸模式开启1小时,关闭1小时功能是否正常 self.write_report(GNY201STimerFish3) # 440, FUT_MTIMER_FISH_鱼缸模式开启2分钟,关闭2分钟功能是否正常 # self.write_report(GNY201STimerFish4) # 438, FUT_MTIMER_FISH_鱼缸模式开启23小时59分钟,关闭23小时59分钟功能是否正常 self.write_report(GNY201STimerFish5) # 436, FUT_MTIMER_FISH_鱼缸模式_循环1次 self.write_report(GNY201STimerFish6) # 435, FUT_MTIMER_FISH_鱼缸模式_循环2次 # self.write_report(GNY201STimerMos1) # 461, FUT_MTIMER_MOS_电蚊香模式_延时功能(1min,2min,1h,23h59min,断电恢复)是否正常 # self.write_report(GNY201STimerOvp1) # 459, FUT_MTIMER_OVP_充电保护模式_延时功能(1min,2min,1h,23h59min,断电恢复)是否正常 self.write_report(GNY201STimerTime1) # 450, FUT_MTIMER_TIME_当前时间在设定时间内模式时间执行 # self.write_report(GNY201STimerTime2) # 446, FUT_MTIMER_TIME_模式定时每日循环 # self.write_report(GNY201STimerTime3) # 445, FUT_MTIMER_TIME_模式定时每周日循环 # self.write_report(GNY201STimerTime4) # 444, FUT_MTIMER_TIME_循环定时每周一循环 self.write_report(GNY201STimerTime5) # 443, FUT_MTIMER_TIME_模式定时状态下手动改变设备状态 # self.write_report(GNY201STimerTime6) # 434, FUT_MTIMER_TIME_设定关闭时间早于开启时间的模式定时执行 self.write_report(GNY201STimerTime7) # 433, FUT_MTIMER_TIME_正常状态下模式定时 database["program_loop_time"] += 1 # 输出报告 def write_report(self, case_name): try: case = case_name(self.device_info).run() end_time = time.strftime("%Y-%m-%d %X") d = (u'[ZENTAO_ID=%s, RESULT=%s CASE_TITLE="%s", RUN_TIMES=%s, CASE_ID=%s, START=%s, CLOSE=%s]' % ( case[0], case[1], case[2], database["program_loop_time"], database["case_location"], case[3], end_time)) self.report.info(d) zentao_id = case[0] xls_data = database[self.device_name] xls_data = xls_data[zentao_id] xls_data["end_time"] = end_time xls_data["row"] = database["case_row"][int(zentao_id)] xls_data["run"] = "Y" self.debug.info("row: %s" % xls_data["row"]) self.xls.write_data(xls_data["row"], xls_data["ZenTao"], xls_data["case_title"], xls_data["end_time"], xls_data["run"], xls_data["test_count"], xls_data["test_pass"], xls_data["test_fail"], xls_data["test_error"], xls_data["test_wait"]) # 列表中的中文能以汉字的形式写入日志中 try: # Python2 self.debug.info("write_data: %s" % json.dumps(xls_data, encoding='UTF-8', ensure_ascii=False)) except TypeError: # Python3 self.debug.info("write_data: %s" % xls_data) database["case_location"] += 1 except BaseException: self.debug.error(traceback.format_exc())
def write_xls(self): self.xls = WriteXls(self.device_info)
class WaitCase(object): def __init__(self, device_list, device_name, m_queue): self.device_list = device_list # 设备列表 self.device_name = device_name # 设备名称 self.device_info = device_list[device_name] # 设备信息表 database["m_queue"] = m_queue # 用于主进程和子进程通讯的消息队列 self.report = None # 初始化结果报告模块 self.xls = None # 初始化执行结果Excel文件模块 self.debug = None # 初始化debug日志模块 self.page = None # 初始化元素库模块 self.device_info_list = {} # 初始化设备信息 self.script_init_success = False # 脚本初始化结果标志位 database["case_location"] = 1 # 用例执行次数 self.row = 0 # Excel报告写入初始位置 self.sc = ShellCommand() # 实例化ShellCommand self.device_info["sc"] = self.sc database[device_name] = {} # 初始化设备数据库 try: self.create_debug() self.create_report() self.write_xls() self.select_page_element() self.check_appium() self.script_init_success = True except BaseException: self.debug.error(traceback.format_exc()) raise if self.script_init_success is True: self.run() else: raise ScriptInitError( "Script Init Error!!! " "contain [create_debug(), create_log(), " "create_report(), write_xls(), check_appium()]") # 从元素库筛选对应APP元素库 def select_page_element(self): self.page = PageElement( self.device_info["platformName"]).get_page_element() self.device_info["page"] = self.page # 生成log格式运行结果 def create_report(self): self.report = check_report(self.device_info) self.device_info["report"] = self.report # 生成debug日志 def create_debug(self): self.debug = check_debug(self.device_info) self.device_info["debug"] = self.debug # 实例化Excel文件 def write_xls(self): self.xls = WriteXls(self.device_info) # 检查Appium服务是否启动 def check_appium(self): while True: try: self.sc.find_proc_and_pid_by_port(self.device_info["port"])[0] except IndexError: time.sleep(1) else: self.debug.info("Appium Sever Launch Success! %s" % time.strftime("%Y-%m-%d %X")) break # 开始执行用例 def run(self): # 填写设备信息日志 self.debug.info("*" * 30) self.debug.info(u"[APP_INF]deviceName:.....%s" % self.device_info["deviceName"]) self.debug.info(u"[APP_INF]UDID:...........%s" % self.device_info["udid"]) self.debug.info(u"[APP_INF]platformName:...%s" % self.device_info["platformName"]) self.debug.info(u"[APP_INF]platformVersion:%s" % self.device_info["platformVersion"]) # self.debug.info(u"[APP_INF]appPackage:.....%s" % self.device_info["desired_caps"]["appPackage"]) # self.debug.info(u"[APP_INF]appActivity:....%s" % self.device_info["desired_caps"]["appActivity"]) # self.debug.info(u"[APP_INF]waitActivity:...%s" % self.device_info["desired_caps"]["waitActivity"]) # self.debug.info(u"[APP_INF]bundleId:.......%s" % self.device_info["desired_caps"]["bundleId"]) # self.debug.info("******************************") for name, blank in [["appPackage", 5], ["appActivity", 4], ["waitActivity", 3], ["bundleId", 7]]: try: self.debug.info(u"[APP_INF]%s:%s%s" % (name, "." * blank, self.device_info["desired_caps"][name])) except KeyError: pass self.debug.info("*" * 30) # 执行用例 while True: self.debug.info("run times [%s]" % database["program_loop_time"]) self.write_report(GNY201HControl1) # 2106, 在线状态,频繁开关操作后,状态检查 self.write_report(GNY201HControl2) # 2105, 在线状态,开关操作后,状态检查 self.write_report( GNY201HDelayTimer1) # 2100, 延时定时设置后,改变设备状态后查看延时定时的执行状态 self.write_report(GNY201HDelayTimer2) # 2099, 在线状态,1组单关的延时定时执行状态检查 self.write_report(GNY201HDelayTimer3) # 2098, 在线状态,1组单开的延时定时执行状态检查 # self.write_report(GNY201HNormalTimer1) # 2079, 在线状态,临界点1组开与1组关的定时执行状态检查 # self.write_report(GNY201HNormalTimer2) # 2064, 在线状态,4组开与4组关按自定义方式执行的定时执行状态检查 # self.write_report(GNY201HNormalTimer3) # 2063, 在线状态,4组开与4组关按周末方式执行的定时执行状态检查 # self.write_report(GNY201HNormalTimer4) # 2062, 在线状态,4组开与4组关按工作日方式执行的定时执行状态检查 self.write_report( GNY201HNormalTimer5) # 2061, 在线状态,4组开与4组关单次执行的定时执行状态检查 # self.write_report(GNY201HNormalTimer6) # 2060, 在线状态,1组开与1组关按自定义方式执行的定时执行状态检查 # self.write_report(GNY201HNormalTimer7) # 2059, 在线状态,1组开与1组关按周末执行的定时执行状态检查 # self.write_report(GNY201HNormalTimer8) # 2058, 在线状态,1组开与1组关按工作日执行的定时执行状态检查 # self.write_report(GNY201HNormalTimer9) # 2057, 在线状态,临界点1组开与1组关的定时执行状态检查 self.write_report( GNY201HNormalTimer10) # 2056, 在线状态,1组开与1组关定时执行状态检查 self.write_report(GNY201HNormalTimer11) # 2055, 在线状态,1组单关定时执行状态检查 self.write_report(GNY201HNormalTimer12) # 2054, 在线状态,1组单开定时执行状态检查 self.write_report(GNY201HOtherFunc1) # 2088, APP查看信息功能 # self.write_report(GNY201HSmartLink1) # 2048, 设备首次配网操作检查 self.write_report(GNY201HTimerFunc1) # 2023, 延时定时的定时数量检查 self.write_report(GNY201HTimerFunc2) # 2022, 普通定时的定时数量检查 self.write_report(GNY201HTimerFunc3) # 2020, 普通定时周期格式检查 database["program_loop_time"] += 1 # 输出报告 def write_report(self, case_name): try: case = case_name(self.device_info).run() end_time = time.strftime("%Y-%m-%d %X") d = ( u'[ZENTAO_ID=%s, RESULT=%s CASE_TITLE="%s", RUN_TIMES=%s, CASE_ID=%s, START=%s, CLOSE=%s]' % (case[0], case[1], case[2], database["program_loop_time"], database["case_location"], case[3], end_time)) self.report.info(d) zentao_id = case[0] xls_data = database[self.device_name] xls_data = xls_data[zentao_id] xls_data["end_time"] = end_time xls_data["row"] = database["case_row"][zentao_id] xls_data["run"] = "Y" self.debug.info("row: %s" % xls_data["row"]) self.xls.write_data(xls_data["row"], xls_data["ZenTao"], xls_data["case_title"], xls_data["end_time"], xls_data["run"], xls_data["test_count"], xls_data["test_pass"], xls_data["test_fail"], xls_data["test_error"], xls_data["test_wait"]) # 列表中的中文能以汉字的形式写入日志中 self.debug.info( "write_data: %s" % json.dumps(xls_data, encoding='UTF-8', ensure_ascii=False)) database["case_location"] += 1 except BaseException: self.debug.error(traceback.format_exc())
class WaitCase(object): def __init__(self, device_list, device_name, m_queue): self.device_list = device_list # 设备列表 self.device_name = device_name # 设备名称 self.device_info = device_list[device_name] # 设备信息表 database["m_queue"] = m_queue # 用于主进程和子进程通讯的消息队列 self.report = None # 初始化结果报告模块 self.xls = None # 初始化执行结果Excel文件模块 self.debug = None # 初始化debug日志模块 self.page = None # 初始化元素库模块 self.device_info_list = {} # 初始化设备信息 self.script_init_success = False # 脚本初始化结果标志位 database["case_location"] = 1 # 用例执行次数 self.row = 0 # Excel报告写入初始位置 self.sc = ShellCommand() # 实例化ShellCommand self.device_info["sc"] = self.sc database[device_name] = {} # 初始化设备数据库 try: self.create_debug() self.create_report() self.write_xls() self.select_page_element() self.check_appium() self.script_init_success = True except BaseException: self.debug.error(traceback.format_exc()) raise if self.script_init_success is True: self.run() else: raise ScriptInitError( "Script Init Error!!! " "contain [create_debug(), create_log(), " "create_report(), write_xls(), check_appium()]") # 从元素库筛选对应APP元素库 def select_page_element(self): self.page = PageElement( self.device_info["platformName"]).get_page_element() self.device_info["page"] = self.page # 生成log格式运行结果 def create_report(self): self.report = check_report(self.device_info) self.device_info["report"] = self.report # 生成debug日志 def create_debug(self): self.debug = check_debug(self.device_info) self.device_info["debug"] = self.debug # 实例化Excel文件 def write_xls(self): self.xls = WriteXls(self.device_info) # 检查Appium服务是否启动 def check_appium(self): while True: try: self.sc.find_proc_and_pid_by_port(self.device_info["port"])[0] except IndexError: time.sleep(1) else: self.debug.info("Appium Sever Launch Success! %s" % time.strftime("%Y-%m-%d %X")) break # 开始执行用例 def run(self): # 填写设备信息日志 self.debug.info("*" * 30) self.debug.info(u"[APP_INF]deviceName:.....%s" % self.device_info["deviceName"]) self.debug.info(u"[APP_INF]UDID:...........%s" % self.device_info["udid"]) self.debug.info(u"[APP_INF]platformName:...%s" % self.device_info["platformName"]) self.debug.info(u"[APP_INF]platformVersion:%s" % self.device_info["platformVersion"]) # self.debug.info(u"[APP_INF]appPackage:.....%s" % self.device_info["desired_caps"]["appPackage"]) # self.debug.info(u"[APP_INF]appActivity:....%s" % self.device_info["desired_caps"]["appActivity"]) # self.debug.info(u"[APP_INF]waitActivity:...%s" % self.device_info["desired_caps"]["waitActivity"]) # self.debug.info(u"[APP_INF]bundleId:.......%s" % self.device_info["desired_caps"]["bundleId"]) # self.debug.info("******************************") for name, blank in [["appPackage", 5], ["appActivity", 4], ["waitActivity", 3], ["bundleId", 7]]: try: self.debug.info(u"[APP_INF]%s:%s%s" % (name, "." * blank, self.device_info["desired_caps"][name])) except KeyError: pass self.debug.info("*" * 30) # 执行用例 while True: self.debug.info("run times [%s]" % database["program_loop_time"]) self.write_report(GNAPPLogin1) # 1889, 登录页面—新用户注册页面跳转 self.write_report(GNAPPLogin2) # 1890, 登录页面—忘记密码页面跳转 self.write_report(GNAPPLogin3) # 1891, 登录页面—登录功能检查 self.write_report( GNAPPLogin4) # 1903, 登录页面—成功登录后杀掉APP,再次开启APP的状态查看 self.write_report(GNAPPLogin5) # 1900, 登录页面—成功登录后注销账号,再次进入登录页面查看 self.write_report( GNAPPLogin6) # 1899, 登录页面—错误密码输入次数超过5次后,账号锁定1分钟验证 self.write_report(GNAPPLogin7) # 1897, 登录页面—错误密码,登录提示信息检查 self.write_report(GNAPPLogin8) # 1898, 登录页面—密码输入超过5次后,信息检查 self.write_report(GNAPPLogin9) # 1896, 登录页面—密码为空,登录提示信息检查 self.write_report(GNAPPLogin10) # 1895, 登录页面—位数错误的数字账号,登录提示信息检查 self.write_report(GNAPPLogin11) # 1894, 登录页面—未注册的手机号码,登录提示信息检查 self.write_report(GNAPPLogin12) # 1893, 登录页面—账号为空,登录提示信息检查 self.write_report(GNAPPLogin13) # 1892, 登录页面—无效账号,登录提示信息检查 self.write_report(GNAPPAccountSettings1) # 1965, 修改密码页面,返回"按钮功能检查" self.write_report(GNAPPAccountSettings2) # 1972, 密码修改后页面跳转确认 self.write_report(GNAPPAccountSettings3) # 1973, 退出当前账号后,取消按钮功能检查 self.write_report(GNAPPAccountSettings4) # 1975, 返回按钮功能确认 self.write_report( GNAPPAccountSettings5) # 1970, 密码修改页面,旧密码输入错误,提示信息检查 self.write_report(GNAPPAccountSettings6) # 1946, 点击昵称"按钮,功能检查" self.write_report(GNAPPAccountSettings7) # 1948, 昵称为空时,功能检查 self.write_report(GNAPPAccountSettings8) # 1949, 昵称修改成功,页面信息检查 self.write_report( GNAPPAccountSettings9) # 1969, 密码修改页面,新密码与确认密码不一致,提示信息检查 self.write_report( GNAPPAccountSettings10) # 1968, 密码修改页面,确认密码为空,提示信息检查 self.write_report( GNAPPAccountSettings11) # 1967, 密码修改页面,新密码与确认密码均为空,提示信息检查 self.write_report( GNAPPAccountSettings12) # 1966, 密码修改页面,旧密码为空,提示信息检查 self.write_report(GNAPPAccountSettings13) # 1947, 昵称长度16位验证,功能检查 self.write_report(GNAPPRegister1) # 1888, 注册页面-已有账户登录按钮,跳转页面检查 self.write_report( GNAPPRegister2) # 1885, 注册页面-正确的用户名和密码,空的验证码,注册验证 self.write_report( GNAPPRegister3) # 1884, 注册页面-正确的用户名和密码,验证码大于6位,注册验证 self.write_report( GNAPPRegister4) # 1883, 注册页面-正确的用户名和密码,错误的6位数字验证码,注册验证 self.write_report( GNAPPRegister5) # 1882, 注册页面-正确的用户名和密码,小于6位数字验证码,注册验证 self.write_report(GNAPPRegister6) # 1881, 注册页面-验证码为特殊字符时,提示信息检查 self.write_report(GNAPPRegister7) # 1880, 注册页面-验证码为中文字符时,提示信息检查 self.write_report(GNAPPRegister8) # 1879, 注册页面-验证码为英文字符时,提示信息检查 self.write_report(GNAPPRegister9) # 1866, 注册页面-密码长度大于16位,注册检查 self.write_report(GNAPPRegister10) # 1840, 注册页面-密码长度小于6位,注册检查 self.write_report(GNAPPRegister11) # 1838, 注册页面-用户名长度小于11位,提示信息检查 self.write_report(GNAPPRegister12) # 1826, 注册页面-用户名长度大于11位,提示信息检查 self.write_report(GNAPPRegister13) # 1825, 注册页面-用户名为空,注册验证 self.write_report(GNAPPRegister14) # 1824, 注册页面-用户名为英文字符时,提示信息检查 self.write_report(GNAPPRegister15) # 1772, 注册页面-用户名为特殊字符时,提示信息检查 self.write_report(GNAPPRegister16) # 1771, 注册页面-用户名为中文字符时,提示信息检查 self.write_report( GNAPPRegister17) # 1769, 注册页面-用户名为数字时(非正确的手机号码),提示信息检查 self.write_report(GNAPPRegister18) # 1768, 注册页面-已经注册过的用户名,再次注册验证 self.write_report( GNAPPForgetPassword1) # 1904, 忘记密码页面-点击"返回"按钮,页面检查 self.write_report(GNAPPForgetPassword2) # 1909, 忘记密码页面-未注册账户检测 self.write_report( GNAPPForgetPassword3) # 1907, 忘记密码页面-点击返回登入界面"按钮,页面检查" self.write_report(GNAPPMessageClassify1) # 1922, 消息分类页面信息检查 self.write_report( GNAPPMessageClassify2) # 1926, 消息设置页面,清空活动历时消息功能检查 self.write_report( GNAPPMessageClassify3) # 1927, 消息设置页面,清空设备历时消息功能检查 self.write_report(GNAPPMessageClassify4) # 1925, 消息设置页面信息检查 self.write_report( GNAPPMessageClassify5) # 1924, 消息分类页面,选择多个设备后的消息内容检查 self.write_report(GNAPPDevicePage1) # 1773, 默认页面信息检查 self.write_report(GNAPPDevicePage2) # 1798, 设备配网过程中,返回按钮功能检查 self.write_report( GNAPPDevicePage3) # 1799, 设备配网过程中,弹出终止配网提示框,取消按钮功能检查 self.write_report( GNAPPDevicePage4) # 1800, 设备配网过程中,弹出终止配网提示框,确定按钮功能检查 self.write_report(GNAPPDevicePage5) # 1807, 配网失败页面信息检查 self.write_report(GNAPPDevicePage6) # 1808, 配网失败页面,取消按钮功能检查 self.write_report(GNAPPFeedBack1) # 1992, 版本信息-当前版本为最新版本,页面信息检查 self.write_report(GNAPPUsingHelp1) # 1975, 返回按钮功能确认 self.write_report(GNAPPThemeStyle1) # 1986, 返回按钮功能检查 self.write_report(GNAPPThemeStyle2) # 1990, 切换为紫色后,查看风格 self.write_report(GNAPPThemeStyle3) # 1989, 切换为橙色后,查看风格 self.write_report(GNAPPThemeStyle4) # 1988, 切换为红色后,查看风格 self.write_report(GNAPPThemeStyle5) # 1987, 切换为绿色后,查看风格 self.write_report(GNAPPThemeStyle6) # 1985, 页面检查 self.write_report(GNAPPVersion1) # 1992, 当前版本为最新版本,页面信息检查 database["program_loop_time"] += 1 # 输出报告 def write_report(self, case_name): try: case = case_name(self.device_info).run() end_time = time.strftime("%Y-%m-%d %X") d = ( u'[ZENTAO_ID=%s, RESULT=%s CASE_TITLE="%s", RUN_TIMES=%s, CASE_ID=%s, START=%s, CLOSE=%s]' % (case[0], case[1], case[2], database["program_loop_time"], database["case_location"], case[3], end_time)) self.report.info(d) zentao_id = case[0] xls_data = database[self.device_name] xls_data = xls_data[zentao_id] xls_data["end_time"] = end_time xls_data["row"] = database["case_row"][int(zentao_id)] xls_data["run"] = "Y" self.debug.info("row: %s" % xls_data["row"]) self.xls.write_data(xls_data["row"], xls_data["ZenTao"], xls_data["case_title"], xls_data["end_time"], xls_data["run"], xls_data["test_count"], xls_data["test_pass"], xls_data["test_fail"], xls_data["test_error"], xls_data["test_wait"]) # 列表中的中文能以汉字的形式写入日志中 try: # Python2 self.debug.info( "write_data: %s" % json.dumps(xls_data, encoding='UTF-8', ensure_ascii=False)) except TypeError: # Python3 self.debug.info("write_data: %s" % xls_data) database["case_location"] += 1 except BaseException: self.debug.error(traceback.format_exc())
class WaitCase(object): def __init__(self, device_list, device_name, m_queue): self.device_list = device_list # 设备列表 self.device_name = device_name # 设备名称 self.device_info = device_list[device_name] # 设备信息表 self.m_queue = m_queue # 用于主进程和子进程通讯的消息队列 database["m_queue"] = m_queue self.report = None # 初始化结果报告模块 self.xls = None # 初始化执行结果Excel文件模块 self.debug = None # 初始化debug日志模块 self.page = None # 初始化元素库模块 self.device_info_list = {} # 初始化设备信息 self.row = 0 # Excel报告写入初始位置 self.device_name = self.device_info["udid"] # 设备名称 self.app = self.device_info["app"] # APP型号 self.serial_port = int(conf["phone_name"][self.device_name]["serial_port"]) self.serial_com = conf["phone_name"][self.device_name]["serial_com"] self.sc = ShellCommand() # 实例化ShellCommand self.device_info["sc"] = self.sc database[device_name] = {} # 初始化设备数据库 database["case_location"] = 1 # 用例执行次数 self.receive_serial = ReceiveSerial() self.serial_command_queue = multiprocessing.Queue() self.serial_result_queue = multiprocessing.Queue() self.device_info["serial_command_queue"] = self.serial_command_queue self.device_info["serial_result_queue"] = self.serial_result_queue self.serial_command_queue.put_nowait((False, "")) # 接收设备串口log alive = multiprocessing.Value('b', True) self.serial_receive_t = multiprocessing.Process(target=self.receive_serial.start_stop_filtrate_data, args=( self.serial_com, self.serial_port, self.serial_command_queue, self.serial_result_queue, alive)) try: self.create_debug() self.serial_receive_t.start() self.create_report() self.write_xls() self.select_page_element() self.check_appium() self.run() alive.value = False # self.serial_receive_t.terminate() # self.serial_receive_t.join() except BaseException: self.debug.error(traceback.format_exc()) self.serial_receive_t.join() os._exit(-1) # 从元素库筛选对应APP元素库 def select_page_element(self): self.page = PageElement(self.device_info["platformName"]).get_page_element() self.device_info["page"] = self.page # 生成log格式运行结果 def create_report(self): self.report = check_report(self.device_info) self.device_info["report"] = self.report # 生成debug日志 def create_debug(self): self.debug = check_debug(self.device_info) self.device_info["debug"] = self.debug # 实例化Excel文件 def write_xls(self): self.xls = WriteXls(self.device_info) # 检查Appium服务是否启动 def check_appium(self): while True: try: self.sc.find_proc_and_pid_by_port(self.device_info["port"])[0] except IndexError: time.sleep(1) else: self.debug.info("Appium Sever Launch Success! %s" % time.strftime("%Y-%m-%d %X")) break # 开始执行用例 def run(self): # 填写设备信息日志 self.debug.info("*" * 30) self.debug.info(u"[APP_INF]deviceName:.....%s" % self.device_info["deviceName"]) self.debug.info(u"[APP_INF]UDID:...........%s" % self.device_info["udid"]) self.debug.info(u"[APP_INF]platformName:...%s" % self.device_info["platformName"]) self.debug.info(u"[APP_INF]platformVersion:%s" % self.device_info["platformVersion"]) # self.debug.info(u"[APP_INF]appPackage:.....%s" % self.device_info["desired_caps"]["appPackage"]) # self.debug.info(u"[APP_INF]appActivity:....%s" % self.device_info["desired_caps"]["appActivity"]) # self.debug.info(u"[APP_INF]waitActivity:...%s" % self.device_info["desired_caps"]["waitActivity"]) # self.debug.info(u"[APP_INF]bundleId:.......%s" % self.device_info["desired_caps"]["bundleId"]) # self.debug.info("******************************") for name, blank in [["appPackage", 5], ["appActivity", 4], ["waitActivity", 3], ["bundleId", 7]]: try: self.debug.info(u"[APP_INF]%s:%s%s" % (name, "." * blank, self.device_info["desired_caps"][name])) except KeyError: pass self.debug.info("*" * 30) # 执行用例 times = 1 while times: self.debug.info("run times [%s]" % database["program_loop_time"]) self.write_report(GNF1331AppInfomation1) # 007,设备详细界面,信息检测 # self.write_report(GNF1331Compatibility1) # 162,不同路由器同一手机一键配网兼容性检查 # self.write_report(GNF1331Electricity1) # 71,app显示功率为0,显示效果检查 self.write_report(GNF1331DeviceInfo1) # 1170, 设置记忆模式 # self.write_report(GNF1331DeviceInfo2) # 1307, 启动鱼缸模式定时,APP中开关状态检查 self.write_report(GNF1331KeyMemory1) # 194, 手机APP远程频繁操作总开关,设备状态检查 self.write_report(GNF1331KeyMemory2) # 193, 手机APP远程总开关功能检查 self.write_report(GNF1331KeyMemory3) # 192, 手机APP远程频繁操作分层开关,设备状态检查 self.write_report(GNF1331KeyMemory4) # 191, 手机APP远程分层开关功能检查 self.write_report(GNF1331Timer1) # 142, 设备设置多模式多定时同层,设备执行检查 self.write_report(GNF1331Timer2) # 141, 设备设置多模式多定时不同层,设备执行状态检查 self.write_report(GNF1331Timer3) # 140, 设备连接大功率设备,定时执行状态检查 self.write_report(GNF1331Timer4) # 139, 设备当前状态和循环定时输出状态相同,循环定时执行状态检查 self.write_report(GNF1331Timer5) # 134, 在线状态,多层循环定时执行状态检查 self.write_report(GNF1331Timer6) # 131, 在线状态,单层多次循环定时执行状态检查 self.write_report(GNF1331Timer7) # 130, 在线状态,单层单次循环定时执行状态检查 self.write_report(GNF1331Timer8) # 121, 设备当前状态和延时定时输出状态相同,延时定时执行状态检查 self.write_report(GNF1331Timer9) # 116, 在线状态,各层定时单关延时定时执行状态检查 self.write_report(GNF1331Timer10) # 114, 在线状态,单层定时单关延时定时执行状态检查 self.write_report(GNF1331Timer11) # 111, 设备当前状态和普通定时输出状态相同,定时执行状态检查 self.write_report(GNF1331Timer12) # 106, 在线状态,定时设置时选择执行均不通知,定时执行成功,检查APP是否通知 self.write_report(GNF1331Timer13) # 101, 随机各层设置9组普通定时,执行完成后删除原有定时,再次设置9组普通定时 # self.write_report(GNF1331Timer14) # 97, 在线状态,随机各层设置9组普通定时,周末执行的定时执行状态检查 # self.write_report(GNF1331Timer15) # 96, 在线状态,随机各层设置9组普通定时,工作日执行的定时执行状态检查 # self.write_report(GNF1331Timer16) # 95, 在线状态,随机各层设置9组普通定时,单次执行的定时执行状态检查 # self.write_report(GNF1331Timer17) # 90, 在线状态,4组开与3组关按自定义方式执行的普通定时执行状态检查 # self.write_report(GNF1331Timer18) # 89, 在线状态,4组开与3组关按周末方式方式执行的普通定时执行状态检查 # self.write_report(GNF1331Timer19) # 88, 在线状态,4组开与3组关按工作日方式执行的普通定时执行状态检查 # self.write_report(GNF1331Timer20) # 87, 在线状态,单层4组开与3组关单次执行的普通定时执行状态检查 # self.write_report(GNF1331Timer21) # 80, 在线状态,单层1组开与1组关按自定义执行的普通定时执行状态检查 # self.write_report(GNF1331Timer22) # 79, 在线状态,单层1组开与1组关按工作日执行的普通定时执行状态检查 # self.write_report(GNF1331Timer23) # 78, 在线状态,单层临界点1组开与1组关的普通定时执行状态检查 self.write_report(GNF1331Timer24) # 77, 在线状态,单层定时1组开与1组关普通定时执行状态检查 self.write_report(GNF1331Timer25) # 76, 在线状态,单层定时单关普通定时执行状态检查 self.write_report(GNF1331Timer26) # 75, 在线状态,单层定时单开普通定时执行状态检查 self.write_report(GNF1331Timer27) # 73, 设备可接受最大额外定时组数检测 self.write_report(GNF1331Timer28) # 72, APP默认定时数组检测 # self.write_report(GNF1331Unbind1) # 167,带负载APP端解绑功能检查 # self.write_report(GNF1331Unbind2) # 166,APP端解绑功能检查 database["program_loop_time"] += 1 times -= 1 # 输出报告 def write_report(self, case_name): try: case = case_name(self.device_info).run() end_time = time.strftime("%Y-%m-%d %X") d = (u'[ZENTAO_ID=%s, RESULT=%s CASE_TITLE="%s", RUN_TIMES=%s, CASE_ID=%s, START=%s, CLOSE=%s]' % ( case[0], case[1], case[2], database["program_loop_time"], database["case_location"], case[3], end_time)) self.report.info(d) zentao_id = case[0] xls_datas = database[self.device_name] xls_data = xls_datas[zentao_id] xls_data["end_time"] = end_time xls_data["row"] = database["case_row"][int(zentao_id)] xls_data["run"] = "Y" self.debug.info("row: %s" % xls_data["row"]) self.xls.write_data(xls_data["row"], xls_data["ZenTao"], xls_data["case_title"], xls_data["end_time"], xls_data["run"], xls_data["test_count"], xls_data["test_pass"], xls_data["test_fail"], xls_data["test_error"], xls_data["test_wait"]) # 列表中的中文能以汉字的形式写入日志中 try: # Python2 self.debug.info("write_data: %s" % json.dumps(xls_data, encoding='UTF-8', ensure_ascii=False)) except TypeError: # Python3 self.debug.info("write_data: %s" % xls_data) database["case_location"] += 1 except BaseException: self.debug.error(traceback.format_exc())
class WaitCase(object): def __init__(self, device_list, device_name, m_queue): self.device_list = device_list # 设备列表 self.device_name = device_name # 设备名称 self.device_info = device_list[device_name] # 设备信息表 database["m_queue"] = m_queue # 用于主进程和子进程通讯的消息队列 self.report = None # 初始化结果报告模块 self.xls = None # 初始化执行结果Excel文件模块 self.debug = None # 初始化debug日志模块 self.page = None # 初始化元素库模块 self.device_info_list = {} # 初始化设备信息 self.script_init_success = False # 脚本初始化结果标志位 database["case_location"] = 1 # 用例执行次数 self.row = 0 # Excel报告写入初始位置 self.sc = ShellCommand() # 实例化ShellCommand self.device_info["sc"] = self.sc database[device_name] = {} # 初始化设备数据库 try: self.create_debug() self.create_report() self.write_xls() self.select_page_element() self.check_appium() self.script_init_success = True except BaseException: self.debug.error(traceback.format_exc()) raise if self.script_init_success is True: self.run() else: raise ScriptInitError( "Script Init Error!!! " "contain [create_debug(), create_log(), " "create_report(), write_xls(), check_appium()]") # 从元素库筛选对应APP元素库 def select_page_element(self): self.page = PageElement( self.device_info["platformName"]).get_page_element() self.device_info["page"] = self.page # 生成log格式运行结果 def create_report(self): self.report = check_report(self.device_info) self.device_info["report"] = self.report # 生成debug日志 def create_debug(self): self.debug = check_debug(self.device_info) self.device_info["debug"] = self.debug # 实例化Excel文件 def write_xls(self): self.xls = WriteXls(self.device_info) # 检查Appium服务是否启动 def check_appium(self): while True: try: self.sc.find_proc_and_pid_by_port(self.device_info["port"])[0] except IndexError: time.sleep(1) else: self.debug.info("Appium Sever Launch Success! %s" % time.strftime("%Y-%m-%d %X")) break # 开始执行用例 def run(self): # 填写设备信息日志 self.debug.info("*" * 30) self.debug.info(u"[APP_INF]deviceName:.....%s" % self.device_info["deviceName"]) self.debug.info(u"[APP_INF]UDID:...........%s" % self.device_info["udid"]) self.debug.info(u"[APP_INF]platformName:...%s" % self.device_info["platformName"]) self.debug.info(u"[APP_INF]platformVersion:%s" % self.device_info["platformVersion"]) # self.debug.info(u"[APP_INF]appPackage:.....%s" % self.device_info["desired_caps"]["appPackage"]) # self.debug.info(u"[APP_INF]appActivity:....%s" % self.device_info["desired_caps"]["appActivity"]) # self.debug.info(u"[APP_INF]waitActivity:...%s" % self.device_info["desired_caps"]["waitActivity"]) # self.debug.info(u"[APP_INF]bundleId:.......%s" % self.device_info["desired_caps"]["bundleId"]) # self.debug.info("******************************") for name, blank in [["appPackage", 5], ["appActivity", 4], ["waitActivity", 3], ["bundleId", 7]]: try: self.debug.info(u"[APP_INF]%s:%s%s" % (name, "." * blank, self.device_info["desired_caps"][name])) except KeyError: pass self.debug.info("*" * 30) # 执行用例 while True: self.debug.info("run times [%s]" % database["program_loop_time"]) # self.write_report(GNY201JLogin1) # 0000, 京东微联APP账号登录 # self.write_report(GNY201JCompatibility1) # 1272, 在TP-link品牌的路由器下添加设备检查 # self.write_report(GNY201JElectricityMeter1) # 1117, 电量统计2H功能及精度检查 # self.write_report(GNY201JElectricityMeter2) # 1138, 单一电价验证 # self.write_report(GNY201JElectricityMeter3) # 1139, 峰谷电价验证 # self.write_report(GNY201JElectricityMeter4) # 1150, 电价模式转换 # self.write_report(GNY201JElectricityMeter5) # 1149, 用电图表显示周期设置 # self.write_report(GNY201JElectricityMeter6) # 1151, 单一电价设置 # self.write_report(GNY201JElectricityMeter7) # 1152, 设置峰谷电价 # self.write_report(GNY201JElectricityMeter8) # 1155, 电价设置验证 # self.write_report(GNY201JElectricityMeter9) # 1136, 实时功率检查_2000W # self.write_report(GNY201JElectricityMeter10) # 1135, 实时功率检查_1500W # self.write_report(GNY201JElectricityMeter11) # 1133, 实时功率检查_500W # self.write_report(GNY201JElectricityMeter12) # 1132, 实时功率检查_200W # self.write_report(GNY201JElectricityMeter13) # 1130, 实时功率检查_50W self.write_report(GNY201JAppFunction1) # 1170, 定时记录删除是否成功 self.write_report(GNY201JAppFunction2) # 1307, 启动鱼缸模式定时,APP中开关状态检查 self.write_report(GNY201JKeyMemory1) # 1216, 开关操作及记忆功能 # self.write_report(GNY201JModeTimer1) # 1061, 热水器模式下设定的关闭时间早于开启时间的定时是否正确执行 self.write_report( GNY201JModeTimer2) # 1064, 热水器模式下当前时间在设定时间内的定时是否正确执行 self.write_report( GNY201JModeTimer3) # 1081, 充电保护模式下手动改变设备为关闭状态后,定时结束检查设备状态 self.write_report( GNY201JModeTimer4) # 1083, 充电保护模式下手动改变设备为开启状态后,定时结束检查设备状态 self.write_report(GNY201JModeTimer5) # 1086, 充电保护模式下延时关闭1分钟 self.write_report( GNY201JModeTimer6) # 1103, 鱼缸模式开启1分钟,关闭1分钟定时是否正确执行 # self.write_report(GNY201JModeTimer7) # 1105, 鱼缸模式开启1小时,关闭1小时定时是否正确执行 self.write_report( GNY201JModeTimer8) # 1108, 鱼缸模式开启2分钟,关闭2分钟定时是否正确执行 self.write_report(GNY201JNormalTimer1) # 1161, 普通定时设置后手动改变设备状态为开启 self.write_report(GNY201JNormalTimer2) # 1162, 普通定时设置后手动改变设备状态为关闭 self.write_report(GNY201JNormalTimer3) # 1164, 普通定时最大组数设定_设置12组 self.write_report(GNY201JNormalTimer4) # 1174, 普通定时_设置13组 self.write_report(GNY201JNormalTimer5) # 1181, 普通交叉定时_8分钟 self.write_report(GNY201JNormalTimer6) # 1184, 单次定时开_2分钟 self.write_report(GNY201JNormalTimer7) # 1185, 单次定时关_2分钟 # self.write_report(GNY201JOverDay1) # 1299, 热水器模式设置每日循环 # self.write_report(GNY201JOverDay2) # 1300, 热水器模式在跨天循环下的跨天执行 # self.write_report(GNY201JOverDay3) # 1301, 定时时间早于当前时间的永不循环定时设置 # self.write_report(GNY201JOverDay4) # 1302, 隔天普通定时 # self.write_report(GNY201JOverDay5) # 1304, 每日循环普通定时 # self.write_report(GNY201JOverDay6) # 1305, 鱼缸模式开启23小时59分钟,关闭23小时59分钟定时是否正确执行 # self.write_report(GNY201JOverDay7) # 1306, 充电保护模式下延迟23h59min关闭 database["program_loop_time"] += 1 # 输出报告 def write_report(self, case_name): try: case = case_name(self.device_info).run() end_time = time.strftime("%Y-%m-%d %X") d = ( u'[ZENTAO_ID=%s, RESULT=%s CASE_TITLE="%s", RUN_TIMES=%s, CASE_ID=%s, START=%s, CLOSE=%s]' % (case[0], case[1], case[2], database["program_loop_time"], database["case_location"], case[3], end_time)) self.report.info(d) zentao_id = case[0] xls_data = database[self.device_name] xls_data = xls_data[zentao_id] xls_data["end_time"] = end_time xls_data["row"] = database["case_row"][zentao_id] xls_data["run"] = "Y" self.debug.info("row: %s" % xls_data["row"]) self.xls.write_data(xls_data["row"], xls_data["ZenTao"], xls_data["case_title"], xls_data["end_time"], xls_data["run"], xls_data["test_count"], xls_data["test_pass"], xls_data["test_fail"], xls_data["test_error"], xls_data["test_wait"]) # 列表中的中文能以汉字的形式写入日志中 self.debug.info( "write_data: %s" % json.dumps(xls_data, encoding='UTF-8', ensure_ascii=False)) database["case_location"] += 1 except BaseException: self.debug.error(traceback.format_exc())
class WaitCase(object): def __init__(self, device_list, device_name, m_queue): self.device_list = device_list # 设备列表 self.device_name = device_name # 设备名称 self.device_info = device_list[device_name] # 设备信息表 database["m_queue"] = m_queue # 用于主进程和子进程通讯的消息队列 self.report = None # 初始化结果报告模块 self.xls = None # 初始化执行结果Excel文件模块 self.debug = None # 初始化debug日志模块 self.page = None # 初始化元素库模块 self.device_info_list = {} # 初始化设备信息 self.row = 0 # Excel报告写入初始位置 self.device_name = self.device_info["udid"] # 设备名称 self.app = self.device_info["app"] # APP型号 self.serial_port = int( conf["phone_name"][self.device_name]["serial_port"]) self.serial_com = conf["phone_name"][self.device_name]["serial_com"] self.sc = ShellCommand() # 实例化ShellCommand self.device_info["sc"] = self.sc database[device_name] = {} # 初始化设备数据库 database["case_location"] = 1 # 用例执行次数 self.receive_serial = ReceiveSerial(self.serial_com, self.serial_port) self.serial_receive_t = threading.Thread( target=self.launch_receive_serial) self.serial_command_t = threading.Thread( target=self.receive_serial_command) self.serial_command_queue = Queue.Queue() self.serial_result_queue = Queue.Queue() self.device_info["serial_command_queue"] = self.serial_command_queue self.device_info["serial_result_queue"] = self.serial_result_queue try: self.create_debug() self.serial_receive_t.start() self.serial_command_t.start() self.create_report() self.write_xls() self.select_page_element() self.check_appium() self.run() except BaseException: self.debug.error(traceback.format_exc()) self.receive_serial.serial_sever.close() self.serial_receive_t.join() self.serial_command_t.join() raise ScriptInitError("Script Init Error!!!") # 从元素库筛选对应APP元素库 def select_page_element(self): self.page = PageElement( self.device_info["platformName"]).get_page_element() self.device_info["page"] = self.page # 生成log格式运行结果 def create_report(self): self.report = check_report(self.device_info) self.device_info["report"] = self.report # 生成debug日志 def create_debug(self): self.debug = check_debug(self.device_info) self.device_info["debug"] = self.debug # 实例化Excel文件 def write_xls(self): self.xls = WriteXls(self.device_info) # 检查Appium服务是否启动 def check_appium(self): while True: try: self.sc.find_proc_and_pid_by_port(self.device_info["port"])[0] except IndexError: time.sleep(1) else: self.debug.info("Appium Sever Launch Success! %s" % time.strftime("%Y-%m-%d %X")) break # 接收设备串口log def launch_receive_serial(self): self.receive_serial.receive_log() def receive_serial_command(self): self.serial_command_queue.put_nowait((False, "", "")) self.receive_serial.start_stop_filtrate_data(self.serial_command_queue) # 开始执行用例 def run(self): # 填写设备信息日志 self.debug.info("*" * 30) self.debug.info(u"[APP_INF]deviceName:.....%s" % self.device_info["deviceName"]) self.debug.info(u"[APP_INF]UDID:...........%s" % self.device_info["udid"]) self.debug.info(u"[APP_INF]platformName:...%s" % self.device_info["platformName"]) self.debug.info(u"[APP_INF]platformVersion:%s" % self.device_info["platformVersion"]) # self.debug.info(u"[APP_INF]appPackage:.....%s" % self.device_info["desired_caps"]["appPackage"]) # self.debug.info(u"[APP_INF]appActivity:....%s" % self.device_info["desired_caps"]["appActivity"]) # self.debug.info(u"[APP_INF]waitActivity:...%s" % self.device_info["desired_caps"]["waitActivity"]) # self.debug.info(u"[APP_INF]bundleId:.......%s" % self.device_info["desired_caps"]["bundleId"]) # self.debug.info("******************************") for name, blank in [["appPackage", 5], ["appActivity", 4], ["waitActivity", 3], ["bundleId", 7]]: try: self.debug.info(u"[APP_INF]%s:%s%s" % (name, "." * blank, self.device_info["desired_caps"][name])) except KeyError: pass self.debug.info("*" * 30) # 执行用例 while True: self.debug.info("run times [%s]" % database["program_loop_time"]) # self.write_report(GNF1331NormalTimer1) # 1216, 上层循环定时 # self.write_report(GNF1331NormalTimer2) # 1216, 上、中层循环定时 # self.write_report(GNF1331NormalTimer3) # 1216, 上、中、下层循环定时 # self.write_report(GNF1331NormalTimer4) # 1216, 上层延迟定时 # self.write_report(GNF1331NormalTimer5) # 1216, 上、中层延迟定时 # self.write_report(GNF1331NormalTimer6) # 1216, 上、中、下层延迟定时 # self.write_report(GNF1331NormalTimer7) # 1216, 上层普通定时 self.write_report(GNF1331NormalTimer8) # 1216, 上、中层普通定时 # self.write_report(GNF1331NormalTimer9) # 1216, 上、中、下层普通定时 # self.write_report(GNF1331NormalTimer10) # 1216, 上层延迟、中层循环定时、下层普通定时开、关 database["program_loop_time"] += 1 # 输出报告 def write_report(self, case_name): try: case = case_name(self.device_info).run() end_time = time.strftime("%Y-%m-%d %X") d = ( u'[ZENTAO_ID=%s, RESULT=%s CASE_TITLE="%s", RUN_TIMES=%s, CASE_ID=%s, START=%s, CLOSE=%s]' % (case[0], case[1], case[2], database["program_loop_time"], database["case_location"], case[3], end_time)) self.report.info(d) zentao_id = case[0] xls_datas = database[self.device_name] xls_data = xls_datas[zentao_id] xls_data["end_time"] = end_time xls_data["row"] = database["case_row"][zentao_id] xls_data["run"] = "Y" self.debug.info("row: %s" % xls_data["row"]) self.xls.write_data(xls_data["row"], xls_data["ZenTao"], xls_data["case_title"], xls_data["end_time"], xls_data["run"], xls_data["test_count"], xls_data["test_pass"], xls_data["test_fail"], xls_data["test_error"], xls_data["test_wait"]) # 列表中的中文能以汉字的形式写入日志中 self.debug.info( "write_data: %s" % json.dumps(xls_data, encoding='UTF-8', ensure_ascii=False)) database["case_location"] += 1 except BaseException: self.debug.error(traceback.format_exc())