def getTestDataByIndex(self, id): # idよりデータ取得 index = self.__testId.index(id) image = self.__testImage[index] annotation = Common.cvtObjects2Points(self.__testAnnotation[index]["annotation"]["object"]) # bing結果の読み込み bingResultsPath = self.__datasetPath + "/" + self.__BING_RESULT_PATH % (self.__bingProjectName, id) bingResults = Common.readCSV(bingResultsPath) bingResults = bingResults[:min(len(bingResults), self.__PROPOSAL_NUMBER)] testData = [] testLabel = [] testPoint = [] for bingResult in bingResults: score, xmin, ymin, xmax, ymax = bingResult score, xmin, ymin, xmax, ymax = int(score), int(xmin), int(ymin), int(xmax), int(ymax) bbPoint = [xmin, ymin, xmax, ymax] bbImage = cv2.resize(image[ymin:ymax,xmin:xmax], (self.__imageSize, self.__imageSize)) if Common.maxInterUnio(bbPoint, annotation) >= 0.5: bbLabel = self.__classConfig["car"] else: bbLabel = self.__classConfig["none"] testData.append(bbImage) testLabel.append(bbLabel) testPoint.append(bbPoint) testData = np.asarray(testData).astype(np.float32).transpose(0,3,1,2) / 255 testLabel = np.asarray(testLabel).astype(np.int32) testPoint= np.asarray(testPoint).astype(np.int32) return testData, testLabel, testPoint, image, annotation
def start_apps(appflie ='applist.txt'): #serino = "MDEVICE" serino = "e5a8e6d3" if len(sys.argv)>1: serino = sys.argv[1] mod = Common(serino, "Tasking") f = open(appflie) Info() for name in f.readlines(): #print name.strip() mod.start_app(name.strip()) Info() f.close()
class C27467_Gameroom_Cheat_Display(TestCase): ''' 防作弊房间外UI显示 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 20 def pre_test(self): self.common = Common() self.hall_page = Hall_Page() self.game_page = Game_Page() self.yuepai_page = Yuepai_Page() self.start_step("初始化driver") self.luadriver = self.common.setupdriver() self.common.closeactivity(self.luadriver) def room_cheat(self,game_list,is_next=False,switch=1): for i in range(len(game_list)): self.start_step("进入 %s 标准场_作弊场" % game_list[i].get_attribute("name")) game_list[i].click() if(self.game_page.game_is_download()==False): self.log_info("下载游戏ID:%s 失败" % game_list[i].get_attribute("name")) self.game_page.screenshot("%s_downfail.png" % game_list[i].get_attribute("name")) try: self.hall_page.wait_element("关闭对话框").click() except: print "关闭弹框" continue if switch==1: self.game_page.wait_element("反作弊icon") self.game_page.screenshot("_%s_cheat.png" % game_list[i].get_attribute("name")) else: self.game_page.element_is_exist("反作弊icon") ==False self.game_page.screenshot("_%s_nocheat.png" % game_list[i].get_attribute("name")) try: self.game_page.wait_element("返回1").click() except: self.log_info("从 %s 标准场返回大厅失败" % game_list[i].get_attribute("name")) if is_next == True: self.log_info("is_next为True则表示遍历的是第二页的子游戏") try: self.game_page.wait_element("右三角标").click() except: self.log_info("当前为第二页") def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step("获取首屏子游戏列表,并设置为作弊场") game_list = self.game_page.get_game_list() self.common.room_set_cheat(game_list,switch=1) self.room_cheat(game_list,switch=1) self.start_step("首屏子游戏列表设置为非作弊场") self.common.room_set_cheat(game_list,switch=0) self.start_step("获取第二页的子游戏") if (self.game_page.element_is_exist("右三角标") == True): self.game_page.wait_element("右三角标").click() else: self.game_page.wait_element("左三角标").click() self.start_step("获取第二页子游戏列表,并设置为作弊场") game_list1 = self.game_page.get_game_list() self.common.room_set_cheat(game_list1,switch=1) self.room_cheat(game_list1,is_next=True,switch=1) self.start_step("第二页子游戏列表设置为非作弊场") self.common.room_set_cheat(game_list1,switch=0) self.start_step("查看非作弊场的游戏") self.common.switchserver() self.common.closeActivityBtn() self.room_cheat(game_list, switch=0) self.room_cheat(game_list1,is_next=True,switch=0) def post_test(self): ''' 测试用例执行完后,清理测试环境 ''' self.common.closedriver()
class C31261_DFQP_Match_Invitational1(TestCase): ''' 大厅比赛场---邀请赛创建页面 ''' owner = "MindyZhang" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.common = Common() #初始化luadriver print("pre_test") self.luadriver = self.common.setupdriver() self.common.closeactivityprepublish(self.luadriver) #关闭活动弹框 time.sleep(10) self.hall_page = Hall_Page() self.match_page = Match_Page() def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") time.sleep(5) self.start_step("点击比赛场按钮") self.hall_page.wait_element("比赛场").click() time.sleep(3) self.start_step("点击邀请赛") self.match_page.wait_element("比赛场-邀请赛").click() time.sleep(3) self.match_page.screenshot("1.png") time.sleep(3) self.start_step("创建邀请赛") self.match_page.wait_element("创建邀请赛").click() time.sleep(3) self.match_page.screenshot("2.png") time.sleep(3) if (self.match_page.is_exist("立即升级") == True): self.match_page.wait_element("立即升级").click() time.sleep(3) # self.match_page.wait_element("已有账号登录").click() # time.sleep(3) #self.common.loginuser(self.casedata['user'],self.casedata['password']) self.match_page.wait_element("手机号码").click() time.sleep(2) # self.match_page.wait_element("手机号码").send_keys('18028781683') # self.match_page.wait_element("密码").send_keys('111111') self.match_page.wait_element("确定").click() time.sleep(10) self.match_page.wait_element("关闭").click() time.sleep(2) else: self.match_page.screenshot("3.png") time.sleep(2) self.match_page.wait_element("箭头返回").click() self.match_page.wait_element("箭头返回").click() time.sleep(3) self.match_page.wait_element("返回").click() self.hall_page.wait_element("同步标志") def post_test(self): ''' 测试用例执行完后,清理测试环境 ''' # self.common.deletefile(self.luadriver) self.common.closedriver()
class C31029_DFQP_Message_Silver(TestCase): ''' 银币私信 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.start_step("初始化环境") self.common = Common() global mid mid = self.common.get_config_value("casecfg", "mid") self.start_step("接口交互道具私信") print coin return1 = PHPInterface.send_message(int(mid), "交互道具私信", "交互道具私信", 0, 2, 0) self.message_page = Message_Page() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.backpack_page = Backpack_Page() def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.element_is_exist("同步标志") self.hall_page.wait_element("同步标志") time.sleep(4) self.start_step("进入消息页面") self.hall_page.wait_element("消息").click() time.sleep(2) self.start_step("查看消息") try: try: element = self.message_page.get_elements("小琪妹") element[1].click() except: self.message_page.wait_element("小琪妹").click() time.sleep(3) self.message_page.screenshot('getcalls1.png') self.start_step("立即领取") self.message_page.wait_element("立即领取").click() time.sleep(3) self.message_page.screenshot('getcalls2.png') self.message_page.wait_element("知道了").click() time.sleep(2) self.message_page.wait_element('已领取').get_attribute( 'text') == "已领取" except: print("没有消息") time.sleep(6) # self.message_page.wait_element("返回").click() # self.hall_page.wait_element("头像").click() # self.hall_page.wait_element("同步标志") dict1 = PHPInterface.get_user_info(user_info['mid']) # 获取玩家信息 coin1 = eval(dict1).get('result', { 'coin': None }).get('coin') # 获取当前银币值 print coin1 # self.assert_equal(True, coin+2,coin1) def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' try: self.common.closedriver() except: self.log_info("close driver fail")
class C31032_DFQP_Message_Three(TestCase): ''' 3种以上物品私信 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.start_step("初始化环境") self.common = Common() global mid mid = self.common.get_config_value("casecfg", "mid") self.start_step("接口交互道具私信") return1 = PHPInterface.send_message(int(mid), "3种以上物品私信", "3种以上物品私信", [10045, 0, 1], 1, 0) # 初始化Luadriver self.luadriver = self.common.setupdriver() self.message_page = Message_Page() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.backpack_page = Backpack_Page() self.start_step("3种以上物品私信") # 每个用例都需要关闭活动,并切换到预发布 self.common.closeactivity(self.luadriver) def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step("查看物品箱") self.hall_page.wait_element("物品箱").click() time.sleep(2) self.hall_page.screenshot('Backpack.png') self.luadriver.keyevent(4) time.sleep(4) self.start_step("进入消息页面") self.hall_page.wait_element("消息").click() time.sleep(2) self.start_step("查看消息") try: try: element = self.message_page.get_elements("小琪妹") element[1].click() except: self.message_page.wait_element("小琪妹").click() time.sleep(3) self.message_page.screenshot('Object.png') self.message_page.wait_element("立即领取").click() time.sleep(3) self.message_page.screenshot('Object2.png') self.message_page.wait_element("知道了").click() time.sleep(2) print self.message_page.wait_element('已领取').get_attribute('text') self.message_page.wait_element('已领取').get_attribute( 'text') == "已领取" except: print("没有消息") time.sleep(6) self.message_page.wait_element("返回").click() self.hall_page.wait_element("头像").click() self.hall_page.wait_element("同步标志") self.start_step("查看物品箱") self.hall_page.wait_element("物品箱").click() time.sleep(2) self.hall_page.screenshot('Backpack2.png') def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' try: self.common.closedriver() except: self.log_info("close driver fail")
def test_007_leave_user(self, payload): '''离职 用户''' payload['path'] = payload['path'].format(User.user_id) Common.check(self, payload) User.user_status = 3 self.test_003_get_user_details_test_001_get_user_details()
class C30991_DFQP_PersonInfo_EnterVIP(TestCase): """ 玩家是vip,点击个人资料,查看VIP特权页面 """ owner = "Lucyliu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): #删除自动登陆文件,置为游客状态 self.common = Common() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() # global user_info # user_info = self.common.get_user() # print user_info # 初始化Luadriver self.luadriver = self.common.setupdriver() # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivity_switchserver(self.luadriver,"预发布") self.start_step("获取用户mid") cid = self.common.get_cid() global mid mid = PHPInterface.get_mid(cid, region=1) print "用户mid为:%s" % mid PHPInterface.set_vip(mid,4) time.sleep(3) def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") # self.start_step("进入头像页面") # self.personinfo_page.wait_element("头像").click() # time.sleep(2) # self.start_step("判断是否登陆") # if not self.common.isloginuser(self.luadriver): # self.common.loginuser(user_info['user'], user_info['password']) # self.common.closeactivity_switchserver(self.luadriver, "预发布") # else: # if self.personinfo_page.wait_element("账号ID").get_attribute('text') != user_info['cid']: # self.common.loginuser(user_info['user'], user_info['password']) # self.common.closeactivity_switchserver(self.luadriver, "预发布") # try: # self.personinfo_page.wait_element("关闭").click() # except: # print "已关闭窗口" # time.sleep(2) self.start_step("进入头像页面") self.personinfo_page.wait_element("头像").click() time.sleep(8) self.personinfo_page.wait_element("了解VIP特权").click() time.sleep(3) self.personinfo_page.screenshot('EnterVIP.png') self.luadriver.keyevent(4) time.sleep(2) self.personinfo_page.wait_element("头像logo") def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' PHPInterface.set_vip(mid,-1) # self.common.release_user(user_info['mid']) # self.common.deletefile(self.luadriver) self.common.closedriver()
class C31192_DFQP_Yuepai_CreateRoom_GameUninstalled(TestCase): ''' 未下载游戏创建约牌房 ''' owner = "YoungLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.common = Common() # 初始化Luadriver capabilities = {} capabilities['noReset'] = False capabilities['resetKeyboard'] = False self.luadriver = self.common.setupdriver() self.yuepai_page = Yuepai_Page() self.hall_page = Hall_Page() self.common.closeactivity_switchserver(self.luadriver, '预发布') def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") time.sleep(1) self.start_step('进入约牌房界面') self.yuepai_page.wait_element('约牌').click() time.sleep(4) self.start_step('进入积分房界面') self.yuepai_page.wait_element('积分房').click() time.sleep(4) self.start_step('点击开房') self.yuepai_page.wait_element('开房').click() time.sleep(4) self.yuepai_page.screenshot('1.png') self.start_step('点击确定') try: self.yuepai_page.wait_element('确定').click() time.sleep(40) except: print '未找到确定按钮' time.sleep(4) Flag = True while Flag: try: self.yuepai_page.wait_element('开房') except: Flag = False try: self.yuepai_page.wait_element('准备') self.yuepai_page.screenshot('3.png') print '成功创建房间' except: print '创建房间失败' time.sleep(10) self.start_step("退出约牌房") self.yuepai_page.wait_element("菜单键").click() time.sleep(3) self.yuepai_page.wait_element("退出键").click() time.sleep(4) self.yuepai_page.screenshot('exit.png') self.yuepai_page.wait_element("返回").click() time.sleep(3) self.hall_page.wait_element("同步标志") def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' # self.common.deletefile(self.luadriver) self.common.closedriver()
def test_001_get_role_ids(self, payload): '''获取所有角色id''' res = Common.check(self, payload) User.role_ids = [i.get('id') for i in res.json().get('data')]
class C27654_CountShowAfterGame(TestCase): ''' 牌局结束查看结算界面显示 ''' owner = "LukeJiang" status = EnumStatus.Design priority = EnumPriority.High timeout = 15 try_find_time = 5 child_game_timeout = 10 # game1500 鞍山麻将 -- 网络特么的有问题 # game24 五狼腿 -- 网络特么的有问题 # game23 托三批 # 1502 三打一 # game25 升级 -- 网络有问题 # game2603 -- 五十k -- 网络有问题 # game203 -- 斗地主 # 棋牌类没有准备按钮, 并且游戏结束后会自动跳出界面,忽略棋牌类游戏 excluded_game = [ 'game20', 'game2002', 'game1500', 'game1502', 'game24', 'game23', 'game25', 'game2603' ] level = 0 pending = True def init(self): self.common = Common() self.hall_page = Hall_Page() self.setting_page = Setting_Page() self.game_page = Game_Page() self.person_info_page = Personinfo_Page() self.start_step("初始化driver") self.luadriver = self.common.setupdriver() self.start_step("关闭弹出框") self.common.closeactivity(self.luadriver) def log_info(self, msg): self.log.info(msg) def _restart_app(self): # 重启游戏 # driver quite self.common.closedriver() # recreate driver self.init() def pre_test(self): self.log = Logger().get_logger() self.log_info("TestCase: 牌局结束查看结算界面显示") self.init() def run_test(self): self.common.switchserver() self.start_step("关闭弹出框") self.common.closeactivity(self.luadriver) time.sleep(15) self.kill_popup_windom() mid = self.common.get_mid() self.log_info("当前用户mid:%s" % str(mid)) r_v = PHPInterface.set_coin(mid, 50000) self.log_info("设置用户 银币数 接口返回值:%s" % str(r_v)) self.common.switchserver() time.sleep(15) self.kill_popup_windom() self.loop_current_page_game() r_v = PHPInterface.set_vip(mid, 5) self.log_info("设置用户 vip 接口返回值:%s" % str(r_v)) self.log_info("第二页游戏") self.game_page.wait_element("右三角标", timesleep=1).click() self.loop_current_page_game() def loop_current_page_game(self): i = self.try_find_time game_list = [] while i: game_list = self.game_page.get_game_list() if len(game_list) != 0: break i = i - 1 time.sleep(1) if len(game_list) == 0: raise Exception("子游戏列表为空") for game in game_list: game_name = game.get_attribute('name') self.log_info("====准备进入子游戏:%s====" % game_name) if game_name in self.excluded_game: #['game20', 'game2002']: continue r_v = PHPInterface.set_match_config( game=int(game_name.replace("game", "")), basechiptype=0, playmode=0, roomlevel=12 + self.level, baseconfig= "BASE_CHIPS=>100,HIGH_LIMIT=>-1,HIGH_LIMIT_EXIT=>-1,SERVICE_FEE=>10,ADDROBOTFLAG=>1,ROBOT_MAX_NUMBER=>2", extraconfig="") self.log_info("设置场次接口返回值:%s" % str(r_v)) if self.enter_game_room(game_name, find_in_elements=False, level=self.level): self.ready() # 游戏开始后 while 1: if not self.try_find_element("换桌"): break time.sleep(1) self.log_info("等待游戏结束") end_time = time.time() + self.child_game_timeout * 60 jdz_has_clicked = False ddz_qf_clicked = False end_tag_showed = False close_btn_showed = False while 1: # 超时10分钟, 睡眠间隔2s ddz_gameover = self.try_find_element( "ddz_gameover", find_in_elements=False) # ready_btn = self.game_page.wait_element("牌局结束标志", timeout=60 * self.child_game_timeout, frequency=2) if ddz_gameover: end_tag_showed = True self.log_info("ddz_gameover: 牌局已结束") close_btn = self.try_find_element( "关闭按钮", page_object=self.hall_page) if close_btn: close_btn_showed = True self.log_info("关闭按钮: 牌局已结束") if end_tag_showed or close_btn_showed: if not close_btn_showed: counter = self.try_find_element( "btnView", find_in_elements=False) if counter: counter.click() self.game_page.screenshot("counter_%s.png" % game_name) break share_btn = self.try_find_element("share_btn", find_in_elements=False) if share_btn: self.log_info("share_btn: 牌局已结束") self.try_find_element("close_btn", find_in_elements=False, try_time=3).click() close_btn_showed = True break if not jdz_has_clicked: jdz = self.try_find_element("callLordBtn", find_in_elements=False) if jdz: jdz.click() # 新斗地主,叫地主按钮会在一瞬间消失,此时点击准备按钮会跑在(0,0)位置 if self.element_exists("退出", page_object=self.game_page, timesleep=1): self.log_info("点击叫地主, 存在退出按钮") self.luadriver.keyevent(4) jdz_has_clicked = True self.log_info("点击叫地主") if not ddz_qf_clicked: qf = self.try_find_element("叫抢场1分", page_object=self.game_page) if qf: qf.click() self.log_info("点击抢分1分") ddz_qf_clicked = True if self.element_exists("退出", page_object=self.game_page, timesleep=1): self.log_info("点击叫抢场1分, 存在退出按钮") self.luadriver.keyevent(4) if time.time() > end_time: self.log_info("游戏超时") raise Exception("玩游戏超时") self.back_to_hall() def enter_game_room(self, target_gamename, find_in_elements=True, level=0, page_object=None): self.log_info("准备进入子游戏:%s" % target_gamename) # 在当前页中点击target子游戏 child_game = None i = self.try_find_time while i: time.sleep(1) self.log_info("获取子游戏:%s" % target_gamename) try: if find_in_elements: child_game = self.hall_page.get_element( target_gamename ) # self.luadriver.find_lua_element_by_name(target_gamename) else: child_game = self.try_find_element( target_gamename, find_in_elements=False ) #self.luadriver.find_lua_element_by_name(target_gamename) except: pass if child_game: break i = i - 1 if child_game: self.log_info("点击子游戏:%s" % target_gamename) child_game.click() else: next_page = self.try_find_element( "right_arrow", find_in_elements=False, try_time=self.try_find_time ) #self.luadriver.find_lua_element_by_name("right_arrow") if next_page: next_page.click() time.sleep(1) if find_in_elements: child_game = self.hall_page.wait_element(target_gamename) else: child_game = self.try_find_element(target_gamename, find_in_elements=False) if child_game: child_game.click() if not child_game: raise Exception("获取不到子游戏") retry_btn = None try: retry_btn = self.game_page.get_element("重新获取1") self.luadriver.keyevent(4) except: pass if retry_btn: return False # 判断是否需要下载资源 download_btn = None try: download_btn = self.game_page.get_element("资源下载-确定") except: pass room_showed = False if download_btn: download_btn.click() # 等待资源下载完成, 等待结束条件: 场次UI出现 self.log_info("开始下载游戏") while 1: if self.element_exists("swf_view", find_in_elements=False): break if self.element_exists("房间场次", find_in_elements=True, page_object=self.game_page): room_showed = True break time.sleep(1) #if self.game_page.wait_element("房间场次", timeout=60 * 10, frequency=1): #break else: if not self.element_exists("swf_view", find_in_elements=False, try_time=self.try_find_time): room_showed = True if not room_showed: market_btns = self.try_find_elements("swf_view", find_in_elements=False, try_time=self.try_find_time) self.log_info("斗地主金银场次选择:%s" % str(market_btns)) if len(market_btns) == 0: raise Exception("获取不到金银场次选择") market_btns[0].click() time.sleep(2) level_btns = self.game_page.wait_element("叫抢初级场").click() #self.log_info("斗地主初中高场次选择:%s" % str(level_btns)) #if len(level_btns) == 0: # raise Exception("获取不到初中高场次选择") #level_btns[0].click() return True else: level = "初级场" if level == 0 else "中级场" if level == 1 else "高级场" # 点击初级场 self.log_info("点击%s" % level) self.game_page.wait_element(level).click() return True def element_exists(self, name, find_in_elements=True, try_time=1, page_object=None, timesleep=0.5): time.sleep(timesleep) target_element = None i = try_time while i: try: if find_in_elements: target_element = page_object.get_element( name, timesleep=1 ) # self.luadriver.find_lua_element_by_name(target_gamename) else: target_element = self.luadriver.find_lua_element_by_name( name) except: pass if target_element: break i = i - 1 if target_element: return True return False def try_find_element(self, name, find_in_elements=True, try_time=1, page_object=None): target_element = None i = try_time while i: try: if find_in_elements: target_element = page_object.get_element( name, timesleep=1 ) # self.luadriver.find_lua_element_by_name(target_gamename) else: target_element = self.luadriver.find_lua_element_by_name( name) except: pass if target_element: break i = i - 1 return target_element def try_find_elements(self, name, find_in_elements=True, try_time=1, page_object=None): target_elements = [] i = try_time while i: try: if find_in_elements: target_elements = page_object.get_elements( name, timesleep=1 ) # self.luadriver.find_lua_element_by_name(target_gamename) else: target_elements = self.luadriver.find_lua_elements_by_name( name) except: pass if target_elements: break i = i - 1 return target_elements if target_elements != None else [] def wait_for_hallstable(self): self.log_info("等待大厅稳定") end_time = time.time() + self.child_game_timeout * 60 while 1: game_list = self.game_page.get_game_list() if len(game_list) != 0: break if time.time() > end_time: raise Exception("等待大厅超时") time.sleep(1) return True def back_to_hall(self, back_time=4): self.log_info("返回到大厅") for i in range(back_time): self.luadriver.keyevent(4) time.sleep(0.5) while 1: if self.wait_for_hallstable() and not self.element_exists( "title", find_in_elements=False, try_time=2): break else: self.luadriver.keyevent(4) return True def ready(self): # 有准备的按准备 self.log_info("有无准备按钮") i = self.try_find_time while i: ready_btn = None try: ready_btn = self.game_page.get_element("准备", timesleep=1) except: pass if ready_btn: self.log_info("点击准备按钮") ready_btn.click() # 新斗地主,准备按钮会在一瞬间消失,此时点击准备按钮会跑在(0,0)位置 if self.element_exists("退出", page_object=self.game_page, timesleep=1): self.log_info("点击准备按钮, 存在退出按钮") self.luadriver.keyevent(4) break i = i - 1 def post_test(self): self.log_info("post test") #self.common.deletefile(self.luadriver) self.luadriver.quit() def kill_popup_windom(self, backtime=4): # 每日签到 popup = self.try_find_element("signupTips1", find_in_elements=False, try_time=2) if popup: self.log_info("每日签到存在") sign = self.try_find_element("rewardIcon", find_in_elements=False, try_time=2) if sign: sign.click() time.sleep(3) self.try_find_element("closeBtn", find_in_elements=False, try_time=2).click() # 问卷调查 暂时没法标识 # 无条件back 4次 for i in range(backtime): self.luadriver.keyevent(4) time.sleep(0.5) # 新手礼包 reward = self.try_find_element("login_money_anim", find_in_elements=False, try_time=2) if reward: t = self.try_find_element("领新手礼包", page_object=self.hall_page) if t: t.click() while 1: if not self.try_find_element( "exitGameView", find_in_elements=False, try_time=2): break else: self.luadriver.keyevent(4)
def start_apps(): serino = "MDEVICE" if len(sys.argv)>1: serino = sys.argv[1] mod = Common(serino, "Tasking") mod.start_all_app()
class C27434_FriendInvitation(TestCase): #暂时不能写 ''' 结算时邀请好友弹框关闭情况 ''' owner = "YoungLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 15 def pre_test(self): self.common = Common() self.hall_page = Hall_Page() self.game_page = Game_Page() self.yuepai_page = Yuepai_Page() self.start_step("初始化环境") self.luadriver = self.common.setupdriver() self.common.closeactivity_switchserver(self.luadriver) def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step('获取mid') self.hall_page.wait_element('测试按钮').click() element = self.luadriver.find_lua_element_by_name('uid') text = element.get_attribute('text') global mid mid = int(re.search('\d+', text).group()) print mid self.hall_page.wait_element('关闭测试页面').click() self.start_step('进入约牌') self.hall_page.wait_element('约牌').click() time.sleep(4) self.start_step('进入记分房') self.yuepai_page.wait_element('记分房').click() elements = self.yuepai_page.get_elements('子游戏') for element in elements: if element.get_attribute('text') == '斗地主': element.click() try: self.yuepai_page.wait_element('确定').click() except: print '已下载' PHPInterface.set_robot_flag(0, 0, 0, 12, 1) Flag = True while Flag: try: self.yuepai_page.wait_element('百分比') except: Flag = False time.sleep(2) self.start_step('点击开房') self.yuepai_page.wait_element('开房').click() time.sleep(5) try: self.yuepai_page.wait_element('准备').click() except: print '已准备' time.sleep(5) self.yuepai_page.wait_element('+邀请').click() time.sleep(2) self.hall_page.screenshot('1.png') Flag = True while Flag: try: self.game_page.wait_element('game20结算框标志') Flag = False except: print '玩牌中' time.sleep(2) self.hall_page.screenshot('2.png') PHPInterface.set_robot_flag(0, 0, 0, 12, 0) def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.set_coin(mid, 10000) self.common.closedriver()
class C27663_Settlement_ShareWithWechatUninstall(TestCase): ''' 无微信情况下点击分享 ''' owner = "YoungLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 15 def pre_test(self): self.common = Common() self.hall_page = Hall_Page() self.game_page = Game_Page() self.start_step("初始化环境") self.luadriver = self.common.setupdriver() self.common.closeactivity_switchserver(self.luadriver) def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step('获取mid') self.hall_page.wait_element('测试按钮').click() element = self.luadriver.find_lua_element_by_name('uid') text = element.get_attribute('text') global mid mid = int(re.search('\d+', text).group()) print mid self.hall_page.wait_element('关闭测试页面').click() self.hall_page.wait_element('葫芦岛麻将').click() try: self.game_page.wait_element('资源下载-确定').click() except: print '游戏已下载' PHPInterface.set_robot_flag(2601, 0, 0, 12, 1) Flag = True while Flag: try: self.hall_page.wait_element('场次名称') Flag = False except: pass time.sleep(1) self.hall_page.wait_element('场次名称').click() time.sleep(5) self.hall_page.wait_element('准备').click() time.sleep(2) self.hall_page.screenshot('进入房间.png') Flag = True while Flag: try: self.game_page.wait_element('game2601换桌') Flag = False except: print '玩牌中' time.sleep(2) self.hall_page.screenshot('结算页面.png') self.game_page.wait_element('game2601分享').click() time.sleep(1) self.hall_page.screenshot('点击分享.png') self.game_page.wait_element('分享到朋友圈').click() self.hall_page.screenshot('点击分享到朋友圈.png') PHPInterface.set_robot_flag(2601, 0, 0, 12, 0) def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.set_coin(mid, 10000) self.common.closedriver()
class C27416_FriendFrame(TestCase): ''' 结算时加好友弹框关闭情况 ''' owner = "YoungLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 15 def pre_test(self): self.common = Common() self.hall_page = Hall_Page() self.game_page = Game_Page() self.start_step("初始化环境") self.luadriver = self.common.setupdriver() self.common.closeactivity_switchserver(self.luadriver) def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step('获取mid') self.hall_page.wait_element('测试按钮').click() element = self.luadriver.find_lua_element_by_name('uid') text = element.get_attribute('text') global mid mid = int(re.search('\d+', text).group()) print mid self.hall_page.wait_element('关闭测试页面').click() self.hall_page.wait_element('葫芦岛麻将').click() try: self.game_page.wait_element('资源下载-确定').click() except: print '游戏已下载' PHPInterface.set_robot_flag(2601, 0, 0, 12, 1) Flag = True while Flag: try: self.hall_page.wait_element('场次名称') Flag = False except: pass time.sleep(1) self.hall_page.wait_element('场次名称').click() time.sleep(5) self.hall_page.wait_element('准备').click() time.sleep(5) Eles = self.game_page.get_elements('游戏内头像') Ele_ymin = Eles[0] for Ele in Eles: if int(Ele.location['y']) < int(Ele_ymin.location['y']): Ele_ymin = Ele Ele_ymin.click() time.sleep(2) self.hall_page.screenshot('游戏内其他玩家头像.png') Flag = True while Flag: try: self.game_page.wait_element('game2601换桌') Flag = False except: print '玩牌中' time.sleep(2) self.hall_page.screenshot('结算页面弹出.png') PHPInterface.set_robot_flag(2601, 0, 0, 12, 0) def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.set_coin(mid, 10000) self.common.closedriver()
class C31154_DFQP_GameRoom_Agenda(TestCase): ''' 子游戏房间列表---点击今日赛程 ''' owner = "MindyZhang" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.common = Common() #初始化luadriver print("pre_test") self.luadriver = self.common.setupdriver() time.sleep(10) self.common.closeactivityprepublish(self.luadriver) #关闭活动弹框 self.hall_page = Hall_Page() self.match_page = Match_Page() self.game_page = Game_Page() def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") time.sleep(5) self.start_step("点击血战到底:") if (self.common.game_is_exist("血战到底") == True): self.game_page.wait_element("血战到底").click() time.sleep(3) self.common.game_is_download() time.sleep(2) self.start_step("点击今日赛程按钮") self.match_page.wait_element("今日赛程").click() time.sleep(3) self.match_page.screenshot("1.png") time.sleep(3) if (self.match_page.is_exist("比赛详情1") == True): self.match_page.wait_element("比赛详情1").click() time.sleep(3) self.match_page.screenshot("2.png") self.match_page.wait_element("关闭").click() time.sleep(2) self.luadriver.keyevent(4) time.sleep(2) else: print("无赛程") self.luadriver.keyevent(4) time.sleep(2) else: print("没有血战到底游戏") self.game_page.wait_element("左三角标").click() def post_test(self): ''' 测试用例执行完后,清理测试环境 ''' # self.common.deletefile(self.luadriver) self.common.closedriver()
class C31166_DFQP_GameRoom4(TestCase): ''' 游戏房间内---牌局未开启时聊天 ''' owner = "MindyZhang" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() # 关闭弹框 self.common.closeactivityprepublish(self.luadriver) self.hall_page = Hall_Page() self.game_page = Game_Page() def run_test(self): ''' 测试用例 ''' self.start_step("点击血战到底:") if (self.common.game_is_exist("血战到底") == True): self.game_page.wait_element("血战到底").click() time.sleep(3) self.common.game_is_download() time.sleep(2) self.game_page.wait_element("快速开始").click() time.sleep(3) self.start_step("点击聊天按钮") self.game_page.wait_element("房间聊天按钮").click() time.sleep(3) self.game_page.screenshot("1.png") self.game_page.wait_element("表情").click() time.sleep(2) elements = self.game_page.get_elements("VIP表情1") print len(elements) if (self.game_page.is_exist("普通表情1") == True): self.game_page.wait_element("普通表情1").click() time.sleep(2) self.game_page.screenshot("2.png") else: self.game_page.wait_element("VIP表情1").click() time.sleep(2) self.game_page.screenshot("2.png") self.game_page.wait_element("房间聊天按钮").click() time.sleep(3) self.game_page.wait_element("常用").click() self.game_page.screenshot("3.png") self.game_page.wait_element("常用1").click() time.sleep(2) self.luadriver.keyevent(4) time.sleep(2) # self.game_page.wait_element("菜单").click() # time.sleep(2) # self.game_page.wait_element("退出").click() # time.sleep(3) self.game_page.wait_element("返回").click() else: print("没有血战到底游戏") self.game_page.wait_element("左三角标").click() def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' # self.common.deletefile(self.luadriver) self.common.closedriver()
class C199_DFQP_Yuepai_CoinCrystalRoom_Display(TestCase): ''' 银币、金条约牌房房间内展示 ''' owner = "YoungLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.common = Common() global user_info user_info = self.common.get_user() print user_info user_info1 = PHPInterface.get_user_info(user_info['mid']) # 获取玩家信息 coin = json.loads(user_info1).get('result', { 'coin': None }).get('coin') # 获取当前银币值 AddMoney = 60000 - coin PHPInterface.add_money(user_info['mid'], AddMoney) # 将银币值设为60000 crystal = json.loads(user_info1).get('result', { 'crystal': None }).get('crystal') # 获取当前金条值 AddCrystal = 1000 - crystal PHPInterface.add_crystal(user_info['mid'], AddCrystal) # 将金条数目置1000 # 初始化Luadriver self.luadriver = self.common.setupdriver() self.yuepai_page = Yuepai_Page() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.common.closeactivity_switchserver(self.luadriver, '预发布') self.hall_page.wait_element("头像").click() time.sleep(5) self.common.loginuser(user_info['user'], user_info['password']) self.common.closeActivityBtn() def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step('进入约牌房界面') self.yuepai_page.wait_element('约牌').click() time.sleep(2) self.start_step('进入银币/金条房界面') self.yuepai_page.wait_element('银币/金条房').click() time.sleep(2) self.start_step('点击银币单选按钮') self.yuepai_page.wait_element('银币单选按钮').click() time.sleep(2) self.start_step('点击开房按钮') self.yuepai_page.wait_element('开房').click() time.sleep(2) self.start_step('点击确定') try: self.yuepai_page.wait_element('确定').click() except: print '未找到确定按钮' Flag = True while Flag: try: self.yuepai_page.wait_element('开房').click() except: Flag = False try: self.yuepai_page.wait_element('准备') print '成功创建银币房' except: print '创建银币房失败' time.sleep(3) self.start_step('点击菜单键') self.yuepai_page.wait_element('菜单键').click() time.sleep(2) self.yuepai_page.screenshot('1.png') self.yuepai_page.wait_element('银币框').click() time.sleep(2) self.start_step('点击二维码按钮') self.yuepai_page.wait_element('二维码').click() time.sleep(2) self.yuepai_page.screenshot('2.png') self.yuepai_page.wait_element('银币框').click() time.sleep(2) self.start_step('点击广播邀人按钮') self.yuepai_page.wait_element('广播邀人').click() time.sleep(2) self.yuepai_page.screenshot('3.png') self.yuepai_page.wait_element('银币框').click() time.sleep(2) self.start_step('点击更多按钮') self.yuepai_page.wait_element('更多').click() time.sleep(2) self.yuepai_page.screenshot('4.png') self.yuepai_page.wait_element('银币框').click() time.sleep(2) self.start_step('点击邀请按钮') self.yuepai_page.wait_element('邀请-银币/金条房').click() time.sleep(2) self.yuepai_page.screenshot('5.png') self.yuepai_page.wait_element('银币框').click() time.sleep(2) self.start_step('点击记牌器按钮') self.yuepai_page.wait_element('记牌器').click() time.sleep(2) self.yuepai_page.screenshot('6.png') self.yuepai_page.wait_element('银币框').click() self.start_step('点击聊天按钮') self.yuepai_page.wait_element('聊天').click() time.sleep(2) self.yuepai_page.screenshot('7.png') self.yuepai_page.wait_element('银币框').click() time.sleep(2) self.start_step('退出银币房,进入金条房') self.yuepai_page.wait_element('菜单键').click() time.sleep(2) self.yuepai_page.wait_element('退出键').click() time.sleep(3) self.yuepai_page.wait_element('银币/金条房').click() time.sleep(2) self.start_step('点击金条单选按钮') self.yuepai_page.wait_element('金条单选按钮').click() time.sleep(2) self.start_step('点击开房按钮') self.yuepai_page.wait_element('开房').click() time.sleep(3) self.yuepai_page.screenshot('8.png') self.start_step("退出约牌房") self.yuepai_page.wait_element("菜单键").click() time.sleep(3) self.yuepai_page.wait_element("退出键").click() time.sleep(4) self.yuepai_page.screenshot('exit.png') self.yuepai_page.wait_element("返回").click() time.sleep(3) self.hall_page.wait_element("同步标志") def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' try: self.common.deletefile(self.luadriver) self.common.closedriver() except: self.log_info("close driver fail") finally: self.common.release_user(user_info['mid'])
class C31229_DFQP_Match_MatchType(TestCase): ''' 大厅比赛场---比赛类型Tab页切换 ''' owner = "MindyZhang" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.common = Common() #初始化luadriver print("pre_test") self.luadriver = self.common.setupdriver() time.sleep(5) self.common.closeactivityprepublish(self.luadriver) self.hall_page = Hall_Page() self.match_page = Match_Page() def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") time.sleep(5) self.start_step("点击比赛场按钮") self.hall_page.wait_element("比赛场").click() time.sleep(3) self.match_page.screenshot("1.png") time.sleep(3) self.start_step("点击切换比赛tab") if (self.match_page.is_exist("话费赛") == True): self.match_page.wait_element("话费赛").click() time.sleep(3) self.match_page.screenshot("2.png") else: print("没有话费赛") if (self.match_page.is_exist("实物赛") == True): self.match_page.wait_element("实物赛").click() time.sleep(3) self.match_page.screenshot("3.png") else: print("没有实物赛") if (self.match_page.is_exist("iphone赛") == True): self.match_page.wait_element("iphone赛").click() time.sleep(3) self.match_page.screenshot("4.png") else: print("没有iphone赛") self.match_page.wait_element("全部比赛").click() time.sleep(3) self.match_page.wait_element("返回").click() self.hall_page.wait_element("同步标志") def post_test(self): ''' 测试用例执行完后,清理测试环境 ''' # self.common.deletefile(self.luadriver) self.common.closedriver()
def test_000_common(self, payload): '''通用测试''' Common.check(self, payload)
class C70449SocreRoom_XialaMemu(TestCase): ''' 记分房内查看菜单下拉框按钮 ''' owner = "StephanieHuang" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivity(self.luadriver) self.hall_page = Hall_Page() self.yuepai_page = Yuepai_Page() def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step("进入约牌房界面") self.yuepai_page.wait_element("约牌").click() self.start_step("创建免费记分房") self.yuepai_page.wait_element('记分房', 20).click() time.sleep(6) self.start_step("获取左边游戏列表") elements = self.yuepai_page.game_list() self.log_info("记分房有个列表个数为:%d个" % len(elements)) for i in range(0, len(elements)): elements[i].click() self.start_step("进入%s记分房" % elements[i].get_attribute("text")) self.yuepai_page.enter_room() self.yuepai_page.screenshot("%d.png" % i) try: self.yuepai_page.wait_element('准备', 30) self.log_info('玩家进入房间后显示了准备按钮,而不是自动准备状态') except: self.log_info('玩家进入房间后没显示准备按钮') self.startStep("点击下拉菜单按钮") self.yuepai_page.wait_element("菜单键").click() self.yuepai_page.screenshot('xialMenu_%d.png' % i) self.startStep("点击设置按钮") self.yuepai_page.wait_element("设置键").click() self.yuepai_page.screenshot('setting_%d.png' % i) self.startStep("关闭设置页面") self.yuepai_page.wait_element("关闭设置").click() self.startStep("点击下拉菜单按钮") self.yuepai_page.wait_element("菜单键").click() self.startStep("点击退出按钮") self.yuepai_page.wait_element("退出键").click() self.yuepai_page.screenshot('exitRoom_%d.png' % i) try: self.yuepai_page.wait_element('记分房').click() except: self.log_info("未返回到记分房页面") def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.closedriver()
def test_006_unfrozen_user(self, payload): '''解冻用户''' payload['path'] = payload['path'].format(User.user_id) Common.check(self, payload) User.user_status = 1 self.test_003_get_user_details_test_001_get_user_details()
class C70453_DFQP_Yuepaifang_Chat(TestCase): ''' 斗地主积分房聊天 ''' owner = "StephanieHuang" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivity(self.luadriver) self.hall_page = Hall_Page() self.yuepai_page = Yuepai_Page() def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step("进入约牌房界面") self.yuepai_page.wait_element("约牌").click() self.start_step("创建免费记分房") self.yuepai_page.wait_element('记分房', 20).click() time.sleep(6) self.start_step("获取左边游戏列表") elements = self.yuepai_page.game_list() self.log_info("记分房有个列表个数为:%d个" % len(elements)) for i in range(0, len(elements)): elements[i].click() self.start_step("进入%s记分房" % elements[i].get_attribute("text")) self.yuepai_page.enter_room() self.yuepai_page.screenshot("%d.png" % i) try: self.yuepai_page.wait_element('准备', 30) self.log_info('玩家进入房间后显示了准备按钮,而不是自动准备状态') except: self.log_info('玩家进入房间后没显示准备按钮') self.startStep("点击聊天按钮") self.yuepai_page.wait_element("聊天").click() self.yuepai_page.screenshot('_%d_chat.png' % i) self.startStep("点击表情tab页") self.yuepai_page.wait_element("表情").click() self.startStep("常用表情tab页") self.yuepai_page.wait_element("常用表情").click() self.yuepai_page.screenshot('_%d_commonface.png' % i) self.startStep("vip表情tab页") self.yuepai_page.wait_element("vip表情").click() self.yuepai_page.screenshot('vipface_%d.png' % i) self.startStep("点击聊天记录tab页") self.yuepai_page.wait_element("聊天记录").click() self.yuepai_page.screenshot('_%d_chatrecord.png' % i) self.startStep("切回常用tab页") self.yuepai_page.wait_element("常用").click() self.yuepai_page.screenshot('_%d_common.png' % i) self.start_step("点击玩家头像以关闭聊天界面") self.yuepai_page.wait_element("头像").click() self.start_step("退出约牌房") self.yuepai_page.exit_yuepai_page() try: self.yuepai_page.wait_element('记分房').click() except: self.log_info("未返回到记分房页面") def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' # self.common.deletefile(self.luadriver) self.common.closedriver()
class C30987_DFQP_PersonInfo_Interface_Sex1(TestCase): """ 头像为默认头像,修改性别 """ owner = "Lucyliu" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.common = Common() self.start_step("初始化Luadriver") self.luadriver = self.common.setupdriver() # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivity_switchserver(self.luadriver,"预发布") # global user_info # user_info = self.common.get_user() # print user_info self.start_step("重置默认头像") self.start_step("获取用户mid") cid = self.common.get_cid() mid = PHPInterface.get_mid(cid, region=1) print "用户mid为:%s" % mid PHPInterface.reset_img(mid) self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() def run_test(self): self.hall_page.wait_element("同步标志") # self.start_step("进入头像页面") # time.sleep(2) # self.start_step("判断是否登陆") # if not self.common.isloginuser(self.luadriver): # self.common.loginuser(user_info['user'], user_info['password']) # self.common.closeactivity_switchserver(self.luadriver, "预发布") # else: # if self.personinfo_page.wait_element("账号ID").get_attribute('text') != user_info['cid']: # self.common.loginuser(user_info['user'], user_info['password']) # self.common.closeactivity_switchserver(self.luadriver, "预发布") # try: # self.personinfo_page.wait_element("关闭").click() # except: # print "已关闭窗口" # self.common.closeactivity_switchserver(self.luadriver, "预发布") # self.personinfo_page.screenshot("sex1.png") self.start_step("进入头像页面") self.personinfo_page.wait_element("头像").click() self.start_step("修改性别") print self.personinfo_page.wait_element("女").get_attribute('selected') if(self.personinfo_page.wait_element("女").get_attribute('selected')): self.personinfo_page.wait_element("男").click() else: self.personinfo_page.wait_element("女").click() time.sleep(1) if(self.personinfo_page.wait_element("女").get_attribute('selected')): a=1 else: a=0 print a # 重新登陆 self.personinfo_page.screenshot("sex2.png") self.personinfo_page.wait_element("关闭").click() time.sleep(1) self.start_step("重启游戏查看性别") self.common.restart() self.personinfo_page.wait_element("头像").click() time.sleep(2) if(a==1): self.personinfo_page.wait_element("女").get_attribute('selected') else: self.personinfo_page.wait_element("男").get_attribute('selected') self.personinfo_page.screenshot( 'sex3.png') def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' # self.common.release_user(user_info['mid']) # self.common.deletefile(self.luadriver) self.common.closedriver()
class C27399_Nickname_Sixchar(TestCase): ''' 牌局中查看个人昵称1-6个英文或者其他特殊字符显示 ''' owner = "Lucyliu" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.common = Common() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.game_page = Game_Page() self.yuepai_page = Yuepai_Page() self.start_step("初始化driver") self.luadriver = self.common.setupdriver() # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivity(self.luadriver) def see_nickname(self, is_next=False): game_list = self.game_page.get_game_list() for i in range(len(game_list)): self.start_step("进入子游戏:%s" % game_list[i].get_attribute("name")) game_list[i].click() if (self.game_page.game_is_download() == False): self.log_info("下载游戏ID:%s 失败" % game_list[i]) self.game_page.screenshot("%s_downfail.png" % game_list[i]) try: self.hall_page.wait_element("关闭对话框").click() except: print "关闭弹框" continue try: self.game_page.wait_element("同步标志", 20) self.log_info("进入游戏ID:%s 的房间" % game_list[i].get_attribute("name")) try: self.log_info("进入游戏ID:%s 的第一个玩法" % game_list[i]) elements = self.game_page.game_play_way() elements[0][1].click() except: self.log_info("当前子游戏初级场") self.game_page.wait_element("房间场次").click() starttime = time.time() while self.game_page.element_is_exist("头像frame") == False: time.sleep(1) endtime = time.time() if (endtime - starttime) / 1000 > 20: break self.game_page.screenshot("%s_nickname.png" % game_list[i].get_attribute("name")) except: try: self.hall_page.wait_element("关闭对话框").click() except: self.log_info("未找到元素") try: self.start_step("退出房间") self.yuepai_page.is_exist_yuepairoom() self.game_page.wait_element("返回1").click() if is_next == True: self.log_info("is_next为True则表示遍历的是第二页的子游戏") try: self.game_page.wait_element("右三角标").click() except: self.log_info("当前为第二页") except: self.log_info("未找到元素") def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.hall_page.wait_element("头像").click() self.start_step("修改用户名") nickname = self.common.random_str(6) print nickname self.personinfo_page.wait_element("设置用户名").send_keys(nickname) self.personinfo_page.wait_element("修改用户名").click() #点击页面其他元素,设置保存 self.personinfo_page.wait_element("了解VIP特权").click() self.personinfo_page.screenshot('NicknameAlter.png') self.personinfo_page.wait_element("关闭").click() self.start_step("进入子游戏查看头像") self.start_step("获取首屏子游戏列表") self.see_nickname() while (self.hall_page.element_is_exist("同步标志") == False): self.game_page.wait_element("返回1").click() self.start_step("点击大厅第二页") if (self.game_page.element_is_exist("右三角标") == True): self.game_page.wait_element("右三角标").click() else: self.game_page.wait_element("左三角标").click() self.start_step("获取第二页的子游戏") self.see_nickname(is_next=True) def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.closedriver()
class C31027_DFQP_Message_VIP(TestCase): ''' vip私信 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.start_step("初始化环境") self.common = Common() self.start_step("接口发送vip私信") global mid mid = self.common.get_config_value("casecfg", "mid") return1 = PHPInterface.send_message(int(mid), "接口发送vip私信", "接口发送vip私信", 4, 1, 0) # 初始化Luadriver self.luadriver = self.common.setupdriver() self.message_page = Message_Page() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.backpack_page = Backpack_Page() def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") time.sleep(4) self.start_step("进入消息页面") self.hall_page.wait_element("消息").click() time.sleep(2) self.start_step("查看消息") try: try: element = self.message_page.get_elements("小琪妹") element[1].click() except: self.message_page.wait_element("小琪妹").click() time.sleep(3) self.message_page.screenshot('getcalls1.png') self.message_page.wait_element("立即领取").click() time.sleep(3) self.message_page.screenshot('getcalls2.png') self.message_page.wait_element("知道了").click() time.sleep(2) self.message_page.wait_element('已领取').get_attribute( 'text') == "已领取" except: print("没有消息") time.sleep(3) self.message_page.wait_element("返回").click() self.hall_page.wait_element("头像").click() self.hall_page.wait_element("同步标志") def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' try: self.common.closedriver() except: self.log_info("close driver fail")
def __str__(self): return Common.dict_to_string(self.to_json)
class C31030_DFQP_Message_Gold(TestCase): ''' 金条私信 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.start_step("初始化环境") self.common = Common() global mid mid = self.common.get_config_value("casecfg", "mid") self.start_step("金条私信") global crystal crystal = eval(mid).get('result', { 'crystal': None }).get('crystal') # 获取当前银币值 print crystal return1 = PHPInterface.send_message(int(mid), "金条私信", "金条私信", 1, 1, 0) print return1 # 初始化Luadriver self.luadriver = self.common.setupdriver() self.message_page = Message_Page() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.backpack_page = Backpack_Page() # 每个用例都需要关闭活动,并切换到预发布 self.common.closeactivity(self.luadriver) def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.element_is_exist("同步标志") self.hall_page.wait_element("同步标志") time.sleep(4) self.start_step("进入消息页面") self.hall_page.wait_element("消息").click() time.sleep(2) self.start_step("查看消息") try: try: element = self.message_page.get_elements("小琪妹") element[1].click() except: self.message_page.wait_element("小琪妹").click() time.sleep(3) self.message_page.screenshot('getcalls1.png') self.start_step("立即领取") self.message_page.wait_element("立即领取").click() time.sleep(3) self.message_page.screenshot('getcalls2.png') self.message_page.wait_element("知道了").click() time.sleep(2) self.message_page.wait_element('已领取').get_attribute( 'text') == "已领取" except: print("没有消息") time.sleep(6) crystal1 = eval(mid).get('result', { 'crystal': None }).get('crystal') # 获取当前银币值 print crystal1 self.assert_equal(True, crystal + 1, crystal1) def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' try: self.common.closedriver() except: self.log_info("close driver fail")
class C31194_DFQP_Yuepai_CreateRoom_NotEnoughCrystal(TestCase): ''' 破产金条不够,创建金条约牌房 ''' owner = "YoungLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 15 def pre_test(self): self.common = Common() global user_info, UserID user_info = self.common.get_user() print user_info UserID = user_info.get('mid') print 'UserID:%s' % UserID user_info1 = PHPInterface.get_user_info(UserID) # 获取玩家信息 coin = json.loads(user_info1).get('result', { 'coin': None }).get('coin') # 获取当前银币值 AddMoney = -coin PHPInterface.add_money(UserID, AddMoney) # 将银币值设为0 crystal = json.loads(user_info1).get('result', { 'crystal': None }).get('crystal') # 获取当前金条值 AddCrystal = -crystal PHPInterface.add_crystal(UserID, AddCrystal) # 将金条数目置0 self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.yuepai_page = Yuepai_Page() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.common.closeactivity_switchserver(self.luadriver, '预发布') self.hall_page.wait_element("头像").click() time.sleep(5) self.common.loginuser(user_info['user'], user_info['password']) time.sleep(5) self.common.closeActivityBtn() def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step('进入约牌房界面') self.yuepai_page.wait_element('约牌').click() time.sleep(2) self.start_step('进入银币/金条房界面') self.yuepai_page.wait_element('银币/金条房').click() self.start_step('点击金条单选按钮') self.yuepai_page.wait_element('金条单选按钮').click() self.start_step('点击开房按钮') self.yuepai_page.wait_element('开房').click() try: if (self.yuepai_page.is_exist("立即升级") == True): self.yuepai_page.wait_element("关闭").click() except: print "无立即升级按钮" self.start_step('点击确定') try: self.yuepai_page.wait_element('确定').click() except: print '未找到确定按钮' Flag = True while Flag: self.yuepai_page.wait_element('开房').click() try: self.yuepai_page.wait_element('支付') self.yuepai_page.screenshot('.png') Flag = False except: print '游戏下载中' def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' try: PHPInterface.add_money(UserID, 10000) self.common.deletefile(self.luadriver) self.common.closedriver() except: self.log_info("close driver fail") finally: self.common.release_user(UserID)
class C31026_DFQP_Message_Calls(TestCase): ''' 话费碎片私信 后台配置话费碎片发送私信给玩家,查看私信图标显示并点击领取道具查看动画和背包到账情况 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.start_step("初始化环境") self.common = Common() global mid mid = self.common.get_config_value("casecfg", "mid") return1 = PHPInterface.send_message(int(mid), "接口发送话费碎片私信1", "接口发送话费碎片私信1", 400003, 1, 0) print return1 # 初始化Luadriver self.luadriver = self.common.setupdriver() self.message_page = Message_Page() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.backpack_page = Backpack_Page() self.start_step("接口发送话费碎片私信") # 每个用例都需要关闭活动,并切换到预发布 self.common.closeactivity(self.luadriver) def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step("查看物品箱") self.hall_page.wait_element("物品箱").click() time.sleep(2) self.hall_page.screenshot('getcalls_Backpack.png') self.luadriver.keyevent(4) time.sleep(4) self.start_step("进入消息页面") self.hall_page.wait_element("消息").click() time.sleep(2) self.start_step("查看消息") try: try: element = self.message_page.get_elements("小琪妹") element[1].click() except: self.message_page.wait_element("小琪妹").click() time.sleep(3) self.message_page.screenshot('getcalls1.png') self.message_page.wait_element("立即领取").click() time.sleep(3) self.message_page.screenshot('getcalls2.png') self.message_page.wait_element("知道了").click() time.sleep(2) self.message_page.wait_element('已领取').get_attribute( 'text') == "已领取" except: print("没有消息") time.sleep(3) self.message_page.wait_element("返回").click() self.hall_page.wait_element("头像").click() self.hall_page.wait_element("同步标志") self.start_step("查看物品箱") self.hall_page.wait_element("物品箱").click() time.sleep(2) self.hall_page.screenshot('getcalls_Backpack2.png') def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' try: self.common.closedriver() except: self.log_info("close driver fail")
class C31196_DFQP_Yuepai_CreateCoinRoom_Broke(TestCase): ''' 破产玩家创建银币约牌房 ''' owner = "YoungLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.common = Common() global user_info, UserID user_info = self.common.get_user() print user_info UserID = user_info.get('mid') print 'UserID:%s' % UserID user_info1 = PHPInterface.get_user_info(UserID) # 获取玩家信息 print user_info1 coin = json.loads(user_info1).get('result', { 'coin': None }).get('coin') # 获取当前银币值 AddMoney = -coin PHPInterface.add_money(UserID, AddMoney) # 将银币值设为0 # 初始化Luadriver self.luadriver = self.common.setupdriver() self.yuepai_page = Yuepai_Page() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.common.closeactivity_switchserver(self.luadriver, '预发布') self.hall_page.wait_element("头像").click() time.sleep(5) self.common.loginuser(user_info['user'], user_info['password']) self.common.closeActivityBtn() def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step('进入约牌房界面') self.yuepai_page.wait_element('约牌').click() self.start_step('进入银币/金条房界面') self.yuepai_page.wait_element('银币/金条房').click() self.start_step('点击银币单选按钮') self.yuepai_page.wait_element('银币单选按钮').click() self.start_step('点击开房按钮') self.yuepai_page.wait_element('开房').click() self.start_step('点击确定') try: self.yuepai_page.wait_element('确定').click() except: print '未找到确定按钮' Flag = True while Flag: self.yuepai_page.wait_element('开房').click() try: self.yuepai_page.wait_element('支付1') self.yuepai_page.screenshot('.png') Flag = False except: print '游戏下载中' # self.start_step("退出约牌房") # self.yuepai_page.wait_element("菜单键").click() # time.sleep(3) # self.yuepai_page.wait_element("退出键").click() # time.sleep(4) # self.yuepai_page.screenshot('exit.png') def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' try: PHPInterface.add_money(UserID, 20000) self.common.deletefile(self.luadriver) self.common.closedriver() except: self.log_info("close driver fail") finally: self.common.release_user(UserID)
def run(PATH): logging.debug("function start") # set PATH Common.mkDir(PATH['RESULT']) # read model model = chainer.links.Classifier(Alex()) model.train = False if not os.path.isfile(PATH['MODEL']): raise Exception("モデルが読み込めませんでした") chainer.serializers.load_npz(PATH['MODEL'], model) # output summary CARNUM = [] IDENTIFICATION_CARNUM = [] TPnum = [] FPnum = [] FNnum = [] TNnum = [] TP_15num = [] FP_15num = [] TP_20num = [] FP_20num = [] TP_25num = [] FP_25num = [] TP_30num = [] FP_30num = [] # set test dataset bs = bingTestset(datasetVOC(PATH['DATASET'], 32, False), PATH['BING']) names = bs.getTestIdList() for name in names: logging.debug("start: " + name) # read data images, labels, points, rawImage, bndboxs = bs.getTestDataByIndex(name) # test predictions = testModel(model, images, labels) # output TP = [] # 車両データを車両と認識した座標 FP = [] # 背景データを車両と認識した座標 FN = [] # 車両データを背景と認識した座標 TN = [] # 背景データを背景と認識した座標 for j in range(0, len(predictions)): if (predictions[j] == 1 and labels[j] == 1): TP.append(points[j]) elif(predictions[j] == 1 and labels[j] == 0): FP.append(points[j]) elif(predictions[j] == 0 and labels[j] == 1): FN.append(points[j]) elif(predictions[j] == 0 and labels[j] == 0): TN.append(points[j]) # TP結果と正解データから出力してる。 identificationCar = Common.getIdentificationBndboxFromProposal(bndboxs, TP) # TPとFPに対して,重複矩形の削除を行う。 TP_015 = Common.removeOverlapRect(TP, 0.15) TP_020 = Common.removeOverlapRect(TP, 0.20) TP_025 = Common.removeOverlapRect(TP, 0.25) TP_030 = Common.removeOverlapRect(TP, 0.30) FP_015 = Common.removeOverlapRect(FP, 0.15) FP_020 = Common.removeOverlapRect(FP, 0.20) FP_025 = Common.removeOverlapRect(FP, 0.25) FP_030 = Common.removeOverlapRect(FP, 0.30) # output summary CARNUM.append(len(bndboxs)) IDENTIFICATION_CARNUM.append(len(identificationCar)) TPnum.append(len(TP)) FPnum.append(len(FP)) FNnum.append(len(FN)) TNnum.append(len(TN)) TP_15num.append(len(TP_015)) FP_15num.append(len(FP_015)) TP_20num.append(len(TP_020)) FP_20num.append(len(FP_020)) TP_25num.append(len(TP_025)) FP_25num.append(len(FP_025)) TP_30num.append(len(TP_030)) FP_30num.append(len(FP_030)) # write file if(len(TP)): Common.writeCSV(PATH["RESULT"] + "/" + name + "_TP.csv", xmin=np.array(TP).T[0], ymin=np.array(TP).T[1], xmax=np.array(TP).T[2], ymax=np.array(TP).T[3]) if(len(FP)): Common.writeCSV(PATH["RESULT"] + "/" + name + "_FP.csv", xmin=np.array(FP).T[0], ymin=np.array(FP).T[1], xmax=np.array(FP).T[2], ymax=np.array(FP).T[3]) if(len(FN)): Common.writeCSV(PATH["RESULT"] + "/" + name + "_FN.csv", xmin=np.array(FN).T[0], ymin=np.array(FN).T[1], xmax=np.array(FN).T[2], ymax=np.array(FN).T[3]) if(len(TN)): Common.writeCSV(PATH["RESULT"] + "/" + name + "_TN.csv", xmin=np.array(TN).T[0], ymin=np.array(TN).T[1], xmax=np.array(TN).T[2], ymax=np.array(TN).T[3]) if(len(TP_015)): Common.writeCSV(PATH["RESULT"] + "/" + name + "_TP(0.15).csv", xmin=np.array(TP_015).T[0], ymin=np.array(TP_015).T[1], xmax=np.array(TP_015).T[2], ymax=np.array(TP_015).T[3]) if(len(FP_015)): Common.writeCSV(PATH["RESULT"] + "/" + name + "_FP(0.15).csv", xmin=np.array(FP_015).T[0], ymin=np.array(FP_015).T[1], xmax=np.array(FP_015).T[2], ymax=np.array(FP_015).T[3]) if(len(TP_020)): Common.writeCSV(PATH["RESULT"] + "/" + name + "_TP(0.20).csv", xmin=np.array(TP_020).T[0], ymin=np.array(TP_020).T[1], xmax=np.array(TP_020).T[2], ymax=np.array(TP_020).T[3]) if(len(FP_020)): Common.writeCSV(PATH["RESULT"] + "/" + name + "_FP(0.20).csv", xmin=np.array(FP_020).T[0], ymin=np.array(FP_020).T[1], xmax=np.array(FP_020).T[2], ymax=np.array(FP_020).T[3]) if(len(TP_025)): Common.writeCSV(PATH["RESULT"] + "/" + name + "_TP(0.25).csv", xmin=np.array(TP_025).T[0], ymin=np.array(TP_025).T[1], xmax=np.array(TP_025).T[2], ymax=np.array(TP_025).T[3]) if(len(FP_025)): Common.writeCSV(PATH["RESULT"] + "/" + name + "_FP(0.25).csv", xmin=np.array(FP_025).T[0], ymin=np.array(FP_025).T[1], xmax=np.array(FP_025).T[2], ymax=np.array(FP_025).T[3]) if(len(TP_030)): Common.writeCSV(PATH["RESULT"] + "/" + name + "_TP(0.30).csv", xmin=np.array(TP_030).T[0], ymin=np.array(TP_030).T[1], xmax=np.array(TP_030).T[2], ymax=np.array(TP_030).T[3]) if(len(FP_030)): Common.writeCSV(PATH["RESULT"] + "/" + name + "_FP(0.30).csv", xmin=np.array(FP_030).T[0], ymin=np.array(FP_030).T[1], xmax=np.array(FP_030).T[2], ymax=np.array(FP_030).T[3]) random.shuffle(TP) random.shuffle(FP) random.shuffle(FN) random.shuffle(TN) Common.outputImage(PATH["RESULT"] + "/" + name + "_TP.jpg", rawImage, TP[0:min(2000, len(TP))]) Common.outputImage(PATH["RESULT"] + "/" + name + "_FP.jpg", rawImage, FP[0:min(2000, len(FP))]) Common.outputImage(PATH["RESULT"] + "/" + name + "_FN.jpg", rawImage, FN[0:min(2000, len(FN))]) Common.outputImage(PATH["RESULT"] + "/" + name + "_TN.jpg", rawImage, TN[0:min(2000, len(TN))]) Common.outputImage(PATH["RESULT"] + "/" + name + "_TP(0.15).jpg", rawImage, TP_015) Common.outputImage(PATH["RESULT"] + "/" + name + "_FP(0.15).jpg", rawImage, FP_015) Common.outputImage(PATH["RESULT"] + "/" + name + "_TP(0.20).jpg", rawImage, TP_020) Common.outputImage(PATH["RESULT"] + "/" + name + "_FP(0.20).jpg", rawImage, FP_020) Common.outputImage(PATH["RESULT"] + "/" + name + "_TP(0.25).jpg", rawImage, TP_025) Common.outputImage(PATH["RESULT"] + "/" + name + "_FP(0.25).jpg", rawImage, FP_025) Common.outputImage(PATH["RESULT"] + "/" + name + "_TP(0.30).jpg", rawImage, TP_030) Common.outputImage(PATH["RESULT"] + "/" + name + "_FP(0.30).jpg", rawImage, FP_030) Common.writeCSV(PATH["RESULT"] + "/summary.csv", name=names, carnum=CARNUM, tp=TPnum,fp=FPnum,fn=FNnum,tn=TNnum, tp15=TP_15num, fp15=FP_15num, tp20=TP_20num, fp20=FP_20num, tp25=TP_25num, fp25=FP_25num, tp30=TP_30num, fp30=FP_30num, identificationcarnum=IDENTIFICATION_CARNUM )
class C31197_DFQP_Yuepai_CreateScoreCoinCrystalRoom(TestCase): ''' 玩家成功创建积分、银币、金条约牌房 ''' owner = "YoungLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 10 def pre_test(self): self.common = Common() global user_info, UserID user_info = self.common.get_user() print user_info UserID = user_info.get('mid') print 'UserID:%s' % UserID user_info1 = PHPInterface.get_user_info(UserID) # 获取玩家信息 coin = json.loads(user_info1).get('result', { 'coin': None }).get('coin') # 获取当前银币值 AddMoney = 60000 - coin PHPInterface.add_money(UserID, AddMoney) # 将银币值设为60000 crystal = json.loads(user_info1).get('result', { 'crystal': None }).get('crystal') # 获取当前金条值 AddCrystal = 1000 - crystal PHPInterface.add_crystal(UserID, AddCrystal) # 将金条数目置1000 # 初始化Luadriver self.luadriver = self.common.setupdriver() self.yuepai_page = Yuepai_Page() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.common.closeactivity_switchserver(self.luadriver, '预发布') self.hall_page.wait_element("头像").click() time.sleep(5) self.common.loginuser(user_info['user'], user_info['password']) self.common.closeActivityBtn() def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step('进入约牌房界面') self.yuepai_page.wait_element('约牌').click() time.sleep(3) self.start_step('进入积分房界面') self.yuepai_page.wait_element('积分房').click() time.sleep(4) self.start_step('点击开房按钮') self.yuepai_page.wait_element('开房').click() time.sleep(4) self.start_step('点击确定') try: self.yuepai_page.wait_element('确定').click() except: print '未找到确定按钮' Flag = True while Flag: try: self.yuepai_page.wait_element('开房').click() except: Flag = False try: self.yuepai_page.wait_element('准备') self.yuepai_page.screenshot('1.png') print '成功创建积分房' except: print '创建积分房失败' self.start_step('退出积分房') self.yuepai_page.wait_element('菜单键').click() time.sleep(2) self.yuepai_page.wait_element('退出键').click() self.start_step('进入银币房') time.sleep(2) self.yuepai_page.wait_element('银币/金条房').click() self.yuepai_page.wait_element('银币单选按钮').click() self.start_step('点击开房按钮') self.yuepai_page.wait_element('开房').click() time.sleep(3) try: self.yuepai_page.wait_element('准备ok') self.yuepai_page.screenshot('2.png') print '成功创建银币房' except: print '创建银币房失败' self.start_step('退出银币房') self.yuepai_page.wait_element('菜单键').click() self.yuepai_page.wait_element('退出键').click() self.start_step('进入金条房') time.sleep(2) self.yuepai_page.wait_element('银币/金条房').click() self.yuepai_page.wait_element('金条单选按钮').click() self.start_step('点击开房按钮') self.yuepai_page.wait_element('开房').click() time.sleep(3) try: self.yuepai_page.wait_element('准备ok') self.yuepai_page.screenshot('3.png') print '成功创建金条房' except: print '创建金条房失败' time.sleep(4) self.start_step("退出约牌房") self.yuepai_page.wait_element("菜单键").click() time.sleep(3) self.yuepai_page.wait_element("退出键").click() time.sleep(4) self.yuepai_page.screenshot('exit.png') self.yuepai_page.wait_element("返回").click() time.sleep(3) self.hall_page.wait_element("同步标志") def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' try: self.common.deletefile(self.luadriver) self.common.closedriver() except: self.log_info("close driver fail") finally: self.common.release_user(UserID)
def run(PATH): # set PATH Common.mkDir(PATH['RESULT']) # read model model = chainer.links.Classifier(Alex()) model.train = False if not os.path.isfile(PATH['MODEL']): raise Exception("モデルが読み込めませんでした") chainer.serializers.load_npz(PATH['MODEL'], model) # set test dataset ds= datasetVOC(PATH['DATASET'], 32) tests, rawImages, GTbbBndBoxs, names = ds.getTestDataFromBING(PATH['DATASET-BING'], ".csv", 20000); # output summary CARNUM = [] IDENTIFICATION_CARNUM = [] PPNUM = [] PNNUM = [] NPNUM = [] NNNUM = [] # test for (i, name) in enumerate(names): # output detail PP = [] # 車両データを車両と認識したときTRUE PN = [] # 背景データを車両と認識したときTURE NP = [] # 車両データを背景と認識したときTRUE NN = [] # 背景データを背景と認識したときTRUE XMIN = [] # 矩形の最小X YMIN = [] # 矩形の最小Y XMAX = [] # 矩形の最大X YMAX = [] # 矩形の最大Y GROUNDTRUTH = [] # 正解ラベル PREDICTION = [] # モデルが算出したラベル images, labels, points = tests[i]._datasets rawImage = rawImages[i] bndboxs = GTbbBndBoxs[i] predictions = testModel(model, images, labels) identificationCar = getIdentificationBndboxFromProposal(bndboxs, points) for j in range(0, len(predictions)): PP.append((predictions[j] == 1 and labels[j] == 1)) PN.append((predictions[j] == 1 and labels[j] == 0)) NP.append((predictions[j] == 0 and labels[j] == 1)) NN.append((predictions[j] == 0 and labels[j] == 0)) XMIN.append(points[j][0]) YMIN.append(points[j][1]) XMAX.append(points[j][2]) YMAX.append(points[j][3]) GROUNDTRUTH.append(labels[j]) PREDICTION.append(predictions[j]) # output summary CARNUM.append(len(bndboxs)) IDENTIFICATION_CARNUM.append(len(identificationCar)) PPNUM.append(PP.count(True)) PNNUM.append(PN.count(True)) NPNUM.append(NP.count(True)) NNNUM.append(NN.count(True)) Common.writeCSV(PATH["RESULT"] + "/" + name + ".csv", xmin=XMIN, ymin=YMIN, xmax=XMAX, ymax=YMAX, groudtruth=GROUNDTRUTH, prediction=PREDICTION) Common.writeCSV(PATH["RESULT"] + "/summary.csv", name=names, carnum=CARNUM, pp=PPNUM,pn=PNNUM,np=NPNUM,nn=NNNUM,identificationcarnum=IDENTIFICATION_CARNUM)
class C31198_DFQP_Yuepai_ScoreRoom_Display(TestCase): ''' 积分约牌房房间展示 ''' owner = "YoungLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 15 def pre_test(self): self.common = Common() global user_info, UserID user_info = self.common.get_user() print user_info UserID = user_info.get('mid') # 初始化Luadriver self.luadriver = self.common.setupdriver() self.yuepai_page = Yuepai_Page() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.common.closeactivity_switchserver(self.luadriver, '预发布') self.hall_page.wait_element("头像").click() time.sleep(5) self.common.loginuser(user_info['user'], user_info['password']) self.common.closeActivityBtn() def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step('进入约牌房界面') self.yuepai_page.wait_element('约牌').click() self.start_step('进入积分房界面') self.yuepai_page.wait_element('积分房').click() self.start_step('点击开房按钮') self.yuepai_page.wait_element('开房').click() self.start_step('点击确定') try: self.yuepai_page.wait_element('确定').click() except: print '未找到确定按钮' Flag = True while Flag: try: self.yuepai_page.wait_element('开房').click() except: Flag = False try: self.yuepai_page.wait_element('准备') print '成功创建积分房' except: print '创建积分房失败' time.sleep(3) self.start_step('点击菜单键') self.yuepai_page.wait_element('菜单键').click() time.sleep(3) self.yuepai_page.screenshot('1.png') self.yuepai_page.wait_element('斗地主icon').click() time.sleep(3) self.start_step('点击二维码按钮') self.yuepai_page.wait_element('二维码').click() time.sleep(3) self.yuepai_page.screenshot('2.png') self.yuepai_page.wait_element('斗地主icon').click() time.sleep(3) self.start_step('点击更多按钮') self.yuepai_page.wait_element('更多').click() time.sleep(3) self.yuepai_page.screenshot('3.png') self.yuepai_page.wait_element('斗地主icon').click() time.sleep(3) self.start_step('点击邀请按钮') self.yuepai_page.wait_element('邀请-积分房').click() time.sleep(3) self.yuepai_page.screenshot('4.png') self.yuepai_page.wait_element('斗地主icon').click() time.sleep(3) self.start_step('点击详情按钮') self.yuepai_page.wait_element('详情').click() time.sleep(3) self.yuepai_page.screenshot('5.png') self.yuepai_page.wait_element('斗地主icon').click() time.sleep(3) self.start_step('点击聊天按钮') self.yuepai_page.wait_element('聊天').click() time.sleep(3) self.yuepai_page.screenshot('6.png') self.yuepai_page.wait_element('斗地主icon').click() time.sleep(3) self.start_step('点击准备按钮') self.yuepai_page.wait_element('准备').click() time.sleep(3) self.yuepai_page.screenshot('7.png') self.start_step("退出约牌房") self.yuepai_page.wait_element("菜单键").click() time.sleep(3) self.yuepai_page.wait_element("退出键").click() time.sleep(4) self.yuepai_page.screenshot('exit.png') self.yuepai_page.wait_element("返回").click() time.sleep(3) self.hall_page.wait_element("同步标志") def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' try: self.common.deletefile(self.luadriver) self.common.closedriver() except: self.log_info("close driver fail") finally: self.common.release_user(UserID)