Example #1
0
class TestCase_Initialize(TestCase):
    '''
    用例初始化
    '''
    owner = "LucyLiu"
    status = EnumStatus.Design
    priority = EnumPriority.High
    timeout = 5

    def pre_test(self):
        self.common = Common()
        self.hall_page = Hall_Page()
        self.start_step("初始化Luadriver")
        self.luadriver = self.common.setupdriver()
        self.common.closeactivity()
        # self.common.user_money(money=5000)

    def run_test(self):
        '''
        测试用例
        '''
        self.hall_page.wait_element("同步标志")
        # env = self.common.get_config_value('casecfg', 'env')
        self.start_step("获取mid")
        mid = self.common.get_mid()
        self.common.set_config_value("casecfg", "mid", str(mid))
        print self.common.get_config_value("casecfg", "mid")
        # if env == '1':
        #     self.common.recover_user(str(mid))
        # else:
        #     self.log_info("当前环境非测试环境")

    def post_test(self):
        '''
        测试用例执行完成后,清理测试环境
        '''
        self.common.closedriver()
Example #2
0
class X0004_FourRoom_PlayGame(TestCase):
    '''
    四人场玩牌
    '''
    owner = "LucyLiu"
    status = EnumStatus.Design
    priority = EnumPriority.High
    timeout = 70

    def pre_test(self):
        global starttime,endtime
        starttime=time.time()
        self.common = Common()
        self.hall_page = Hall_Page()
        self.level_page = Level_Page()
        self.game_page = Game_Page()
        env = self.common.get_config_value('casecfg', 'env')
        if env == "0":
            self.log_info("当前环境为正式服")
        elif env == "1":
            mid = self.common.get_config_value('casecfg', 'mid')
            self.common.set_money(mid,5000)

    def gameplay(self):
        i = 1
        self.game_page.wait_element("开始").click()
        self.common.sendTagBroadcast(EnumSceneName.FourRoom, EnumSceneType.Start)
        count = 0
        while self.game_page.element_is_exist("破产对话框",1)==False:
            self.start_step("开始玩第%s场牌" % i)
            while self.game_page.element_is_exist("正在配桌中"):
                self.log_info("正在配桌中,等待")
                time.sleep(3)
                try:
                    self.game_page.wait_element("换桌").click()
                except:
                    self.log_info("换桌失败")
                count += 1
                if (count > 10):
                    self.game_page.is_in_gameroom(singleGlobalVar.get("luaDriver"))
                    self.log_info("等待超时")
                    return
            self.start_step("叫分")
            while self.game_page.element_is_exist("出牌", 1) == False:
                list = ["1分", "2分", "3分"]
                self.log_info("叫分")
                for name in list:
                    try:
                        self.game_page.wait_element(name, 1).click()
                    except:
                        self.log_info("未出现叫分按钮")
                if self.game_page.element_is_exist("继续游戏", 1):
                    break
            if self.game_page.element_is_exist("机器人",1) == False:
                self.game_page.wait_element("托管",0).click()
            while self.game_page.element_is_exist("提示",1) or self.game_page.element_is_exist("出牌",1):
                try:
                    self.game_page.wait_element("提示").click()
                    self.game_page.element_is_exist("出牌").click()
                except:
                    self.log_info("未出现提示按钮")
            while self.game_page.element_is_exist("继续游戏",1)==False:
                time.sleep(1)
                self.log_info("正在游戏中")
                endtime = time.time()
                if (endtime - starttime)/60 > self.timeout - 10:
                    self.game_page.is_in_gameroom(singleGlobalVar.get("luaDriver"))
                    return
            self.common.taskScreenShot("gameover_%s.jpg" % i)
            while self.game_page.element_is_exist("继续游戏", 1):
                while self.game_page.element_is_exist("QQ分享",1):
                    singleGlobalVar.get("luaDriver").keyevent(4)
                self.game_page.wait_element("继续游戏").click()
            while self.game_page.element_is_exist("去底倍场", 1):
                self.game_page.wait_element("去底倍场").click()
            while (self.game_page.element_is_exist("立即领取", 1) or self.game_page.element_is_exist("立即购买", 1)):
                try:
                    self.game_page.wait_element("关闭1").click()
                except:
                    self.log_info("未出现关闭按钮")
                try:
                    self.game_page.wait_element("关闭2").click()
                except:
                    self.log_info("未出现关闭按钮")
                self.game_page.exit_game(singleGlobalVar.get("luaDriver"))
                self.common.user_money(money=5000)
                self.start_step("进入四人场")
                while self.hall_page.element_is_exist("游戏列表"):
                    elments = self.hall_page.get_elements("游戏列表")
                    elments[3].click()
                while self.level_page.element_is_exist("房间列表"):
                    self.level_page.wait_element("房间列表").click()
            while self.game_page.element_is_exist("开始"):
                endtime = time.time()
                if (endtime - starttime) / 60 > self.timeout - 10:
                    break
                self.game_page.wait_element("开始").click()
            i += 1


    def run_test(self):
        self.hall_page.wait_element("同步标志")
        self.start_step("进入四人场")
        while self.hall_page.element_is_exist("游戏列表"):
            elments = self.hall_page.get_elements("游戏列表")
            elments[3].click()
        self.start_step("进入房间")
        while self.level_page.element_is_exist("房间列表"):
            self.level_page.wait_element("房间列表").click()
        self.game_page.wait_element("同步标志")
        self.gameplay()
        time.sleep(5)
        self.common.sendTagBroadcast(EnumSceneName.FourRoom, EnumSceneType.Stop)
Example #3
0
class X0001_ThreeRoom_PlayGame(TestCase):
    '''
    三人场玩牌
    '''
    owner = "ShelleyZhang"
    status = EnumStatus.Design
    priority = EnumPriority.High
    timeout = 60

    def pre_test(self):
        self.common = Common()
        self.hall_page = Hall_Page()
        self.game_page = Game_Page()
        self.threeroom_page = ThreeRoom_Page()
        self.game_page.to_hall_page('大厅头像')

    def play_game(self):
        starttime = time.time()
        self.start_step("进入游戏房间")
        self.threeroom_page.wait_element("点石成金").click()
        self.threeroom_page.wait_element("立即报名").click()
        time.sleep(6)
        self.start_step("添加机器人")
        mid = self.common.get_config_value('casecfg', 'mid')
        print 'mid:%s' % mid
        Interface.add_robot(510, mid, 2)
        while True:
            i = 0
            self.start_step("玩游戏")
            while self.threeroom_page.element_is_exist("跟注", 30):
                elements = self.threeroom_page.get_elements("跟注")
                # endtime = time.time()
                # if (endtime - starttime) / 60 > self.timeout - 3:
                #     self.start_step("玩牌超时了,可以退出游戏了")
                #     return
                if len(elements) >= 2:
                    try:
                        elements[1].click()
                        self.common.taskScreenShot(
                            "threeroom_game_%s.jpg" %
                            str(time.time()).replace('.', ''))
                    except:
                        print "未找到元素"
            endtime = time.time()
            if (endtime - starttime) / 60 > self.timeout - 3:
                self.start_step("玩牌超时了,可以退出游戏了")
                return
            while self.threeroom_page.element_is_exist("再战一场", 2):
                endtime = time.time()
                if (endtime - starttime) / 60 > self.timeout - 3:
                    self.start_step("玩牌一小时,可以退出游戏了")
                    return
                self.threeroom_page.wait_element("再战一场").click()
                i += 1
                print "点击再战%s场" % i
                self.start_step("添加机器人")
                mid = self.common.get_config_value('casecfg', 'mid')
                Interface.add_robot(510, mid, 2)
                time.sleep(5)

            # if self.threeroom_page.element_is_exist("再战一场", 2):
            #     self.threeroom_page.wait_element("再战一场").click()
            #     time.sleep(5)
            #     self.start_step("添加机器人")
            #     mid = self.common.get_config_value('casecfg', 'mid')
            #     Interface.add_robot(510, mid, 2)
            #     time.sleep(3)

    def run_test(self):
        self.common.taskScreenShot("enter_threegame.jpg")
        self.start_step("进入三人场")
        self.threeroom_page.wait_element("三人场", 0).click()
        if self.threeroom_page.element_is_exist("关闭对话框", 2):
            self.threeroom_page.wait_element("关闭对话框").click()
        self.common.sendTagBroadcast(EnumSceneName.ThreeRoom,
                                     EnumSceneType.Start)
        self.play_game()
        # if self.threeroom_page.element_is_exist("点石成金"):
        #     self.play_game()
        time.sleep(5)
        self.common.sendTagBroadcast(EnumSceneName.ThreeRoom,
                                     EnumSceneType.Stop)

    def post_test(self):
        '''
        测试用例执行完成后,清理测试环境
        '''

        self.game_page.to_hall_page('大厅头像')
Example #4
0
class X0003_Knockout_match(TestCase):
    '''
    进入淘汰赛玩牌,持续玩牌一小时
    '''
    owner = "YoungLiu"
    status = EnumStatus.Design
    priority = EnumPriority.High
    timeout = 60

    def pre_test(self):
        self.common = Common()
        self.hall_page = Hall_Page()
        self.game_page = Game_Page()
        self.knockout_page = Knockout_Page()
        self.threeroom_page = ThreeRoom_Page()
        self.game_page.to_hall_page('大厅头像')

    def play(self):
        self.start_step("报名参赛")
        self.knockout_page.wait_element('报名').click()
        time.sleep(5)
        self.start_step("添加机器人")
        mid = self.common.get_config_value('casecfg', 'mid')
        print 'mid:%s' % mid
        Interface.add_robot(510, mid, 5)
        begintime = time.time()
        while True:
            self.common.taskScreenShot("taotai_game_%s.jpg" %
                                       str(time.time()).replace('.', ''))
            while self.knockout_page.element_is_exist("过牌", 30):
                endtime = time.time()
                if ((int(endtime) - int(begintime)) / 60) > (self.timeout - 3):
                    self.common.taskScreenShot("playing_end.jpg")
                    return
                elements = self.knockout_page.get_elements("过牌")
                # print len(elements)
                try:
                    elements[1].click()
                    self.common.taskScreenShot(
                        "taotai_game_%s.jpg" %
                        str(time.time()).replace('.', ''))
                except:
                    print "未找到元素"
            endtime = time.time()
            # print endtime - begintime
            if ((int(endtime) - int(begintime)) / 60) > (self.timeout - 3):
                self.common.taskScreenShot("playing_end.jpg")
                return
            if self.knockout_page.element_is_exist("再战一场", 2):
                self.knockout_page.wait_element('再战一场').click()
                time.sleep(5)
                Interface.add_robot(510, mid, 5)

    def run_test(self):
        self.start_step("进入淘汰赛")
        self.game_page.wait_element("淘汰赛").click()
        self.common.taskScreenShot("knockout.jpg")
        self.common.sendTagBroadcast(EnumSceneName.Knockout,
                                     EnumSceneType.Start)
        self.play()
        time.sleep(10)
        self.common.sendTagBroadcast(EnumSceneName.Knockout,
                                     EnumSceneType.Stop)

    def post_test(self):
        '''
        测试用例执行完成后,清理测试环境
        '''
        self.game_page.to_hall_page('大厅头像')