示例#1
0
class PerTest_QIPAIHALL_Backpack(TestCase):
    '''
    物品箱操作
    '''
    owner = "JessicZeng"
    status = EnumStatus.Design
    priority = EnumPriority.High
    timeout = 5

    def pre_test(self):
        self.common = Common()
        self.hall_page = Hall_Page()
        self.backpack_Page = Backpack_Page()

    def run_test(self):
        '''
        测试步骤
        1、大厅点击物品箱入口
        2、点击兑换记录
        3、点击大厅同步标志,退出物品箱
        '''
        self.hall_page.wait_element("同步标志")

        #点击大厅物品箱入口
        self.start_step("点击大厅物品箱入口")
        self.common.sendTagBroadcast(EnumSceneName.Backpack,
                                     EnumSceneType.Start)

        try:
            #点击物品箱入口
            self.hall_page.get_element("物品箱", 0).click()
            time.sleep(2)
            self.backpack_Page.wait_element("同步标志")
            self.common.taskScreenShot("openBackpackPop.jpg")

            #查看物品箱兑换记录
            self.start_step("查看物品箱兑换记录")
            self.backpack_Page.get_element("兑换记录按钮", 0).click()
            self.backpack_Page.wait_element("兑换记录框同步标志")
            self.common.taskScreenShot("openBackpackPop.jpg")
            self.backpack_Page.get_element("兑换记录框关闭", 0).click()
        except:
            print "操作物品箱失败"
        finally:
            self.common.checkPopVisible(self.backpack_Page)
            self.hall_page.wait_element("同步标志")

        time.sleep(5)
        self.common.sendTagBroadcast(EnumSceneName.Backpack,
                                     EnumSceneType.Stop)
示例#2
0
class PerTest_QIPAIHALL_SafeBox(TestCase):
    '''
    保险箱操作
    '''
    owner = "JessicZeng"
    status = EnumStatus.Design
    priority = EnumPriority.High
    timeout = 5

    def pre_test(self):
        self.common = Common()
        self.hall_page = Hall_Page()
        self.safeBox_Page = Safebox_Page()

    def run_test(self):
        '''
        测试步骤
        1、大厅点击保险箱入口   每次进入都会先金进入银币tab,不用再单独天机银币tab
        3、点击金币保险箱
        4、退出
        '''
        self.hall_page.wait_element("同步标志")

        self.start_step("点击大厅保险箱入口")
        self.common.sendTagBroadcast(EnumSceneName.SafeBox,EnumSceneType.Start)

        try:
            #点击物品箱入口
            self.hall_page.get_element("保险箱",0).click()
            time.sleep(2)
            self.safeBox_Page.wait_element("同步标志")
            self.common.taskScreenShot("silverSafebox.jpg")

            #操作金币保险箱
            self.start_step("操作金条保险箱")
            self.safeBox_Page.get_element("金条tab",0).click()
            time.sleep(1)
            self.common.taskScreenShot("goldSafebox.jpg")
        except:
            self.common.platformLog("操作保险箱失败")

        finally:
            self.common.checkPopVisible(self.safeBox_Page)
            self.hall_page.wait_element("同步标志")

        time.sleep(5)
        self.common.sendTagBroadcast(EnumSceneName.SafeBox, EnumSceneType.Stop)
示例#3
0
class PerTest_QIPAIHALL_Setting(TestCase):
    '''
    设置界面显示
    '''
    owner = "JessicZeng"
    status = EnumStatus.Design
    priority = EnumPriority.High
    timeout = 60

    def pre_test(self):
        self.common = Common()
        self.hall_page = Hall_Page()
        self.setting_page = Setting_Page()
        #通过xpath获取items,是完全返回  因此针对一页显示的item数进行操作
        self.helpItemCount = 5

    def run_test(self):
        '''
        测试用例
        操作步骤:
        1、关闭悬浮球(若已是关闭状态则先打开再关闭)
        2、静音关闭(若已是关闭状态则先打开再关闭)
        3、读牌打开(若已是打开状态则先关闭再打开)
        4、音效、音乐、聊天、震动、比赛围观打开(若已是打开状态则先关闭再打开)
        5、关于查看,四个标签操作步骤:关于--服务协议--隐私策略--版号申明  列表项均滑动  从版号申明往前一直到关于我们  然后点击返回按钮返回设置页面
        6、关于游戏帮助目前所打包不支持,暂不操作
        '''
        self.hall_page.wait_element("同步标志")
        self.common.sendTagBroadcast(EnumSceneName.Setting,
                                     EnumSceneType.Start)
        try:
            self.start_step("点击大厅设置入口")
            self.hall_page.get_element("设置").click()
            self.setting_page.wait_element("同步标志")
            self.common.taskScreenShot("openSettingPop.jpg")
            # 操作各切换按钮
            self.start_step("操作各切换按钮")
            self.common.switchBtn("浮动球开关", "浮动球状态", True)
            self.common.taskScreenShot("closeFloatBall.jpg")
            self.common.switchBtn("静音开关", "静音状态", True)
            self.common.switchBtn("读牌开关", "读牌状态", False)
            self.common.switchBtn("聊天开关", "聊天状态", False)
            self.common.switchBtn("震动开关", "震动状态", False)
            self.common.switchBtn("比赛围观开关", "比赛围观状态", False)

            # 查看关于弹框
            self.start_step("查看关于内容")
            self.setting_page.get_element("关于入口", 0).click()
            self.setting_page.wait_element("关于同步标志")
            self.common.taskScreenShot("setting_about_pop.jpg")
            self.setting_page.get_element("关于我们").click()
            time.sleep(1)
            self.setting_page.get_element("服务协议").click()
            time.sleep(1)
            self.setting_page.get_element("隐私策略").click()
            time.sleep(1)
            self.setting_page.get_element("版本声明").click()
            time.sleep(1)
            self.setting_page.get_element("退出关于", 0).click()

            #查看游戏帮忙
            self.start_step("查看游戏帮助")
            self.setting_page.get_element("游戏帮助入口").click()
            self.setting_page.wait_element("游戏帮助同步标志")
            self.common.taskScreenShot("setting_help_pop.jpg")
            tabList = self.setting_page.get_element("tab列表")
            tabItems = self.setting_page.get_elements("tabItem")
            self.start_step("切换tab,查看不同类型游戏帮助")
            for i in range(self.helpItemCount):
                if (tabItems[i] != None):
                    tabItems[i].click()
                    time.sleep(1)
            if (len(tabItems) > self.helpItemCount):
                self.start_step("滑动左侧tab列表")
                self.common.swipeList(tabList)
            self.setting_page.get_element("退出游戏帮助").click()

            # 退出设置弹框
            self.setting_page.get_element("退出设置", 0).click()
        except:
            self.common.platformLog("设置页面操作失败")
        finally:
            self.common.checkPopVisible(self.setting_page)
            self.hall_page.wait_element("同步标志")

        time.sleep(5)
        self.common.sendTagBroadcast(EnumSceneName.Setting, EnumSceneType.Stop)
示例#4
0
class PerTest_QIPAIHALL_Task(TestCase):
    '''
    任务场景
    '''
    owner = "JessicZeng"
    status = EnumStatus.Design
    priority = EnumPriority.High
    timeout = 60

    def pre_test(self):
        self.common = Common()
        self.hall_page = Hall_Page()
        self.task_page = Task_Page()

    def run_test(self):
        '''
        任务场景测试步骤
        :return:
        '''
        self.hall_page.wait_element("同步标志")
        self.start_step("点击大厅任务入口")
        self.common.sendTagBroadcast(EnumSceneName.Task, EnumSceneType.Start)
        try:
            self.hall_page.get_element("任务", 0).click()
            self.task_page.wait_element("同步标志")
            self.task_page.wait_element("每日签到tab").click()
            time.sleep(2)
            self.common.taskScreenShot("qiandaoView.jpg")

            #若今日签到按钮存在,则点击
            try:
                #若按钮存在并签到成功,会直接跳转到补签页面
                self.task_page.get_element("签到按钮", 0).click()
                time.sleep(1)
            except:
                self.common.platformLog("今日签到按钮不存在or领取今日签到奖励失败")

            #查看购买补签卡界面
            self.start_step("购买补签卡界面")
            self.task_page.wait_element("获取补签卡").click()
            self.task_page.wait_element("补签卡购买框同步标志")
            self.common.taskScreenShot("buyBuqianPop.jpg")
            self.task_page.get_element("取消购买补签卡").click()
            time.sleep(1)

            #进行补签操作,目前没有实际进行补签操作  只是查看补签框
            # try:
            #     buItmes = self.task_page.get_elements("补签item")
            #     print "长度:"+len(buItmes)
            #     if(buItmes != None and len(buItmes) > 0):
            #         buItmes[0].click()
            #         self.task_page.wait_element("补签对话框标志")
            #         time.sleep(1)
            #         self.task_page.get_element("关闭补签对话框").click()
            #     else:
            #         print "!! buItmes != null and len(buItmes) > 0"
            # except:
            #     print "没有可补签项,或执行补签操作失败"

            #查看每日任务列表,若列表可滑动则进行滑动操作
            self.start_step("查看每日任务界面")
            self.task_page.get_element("每日任务tab").click()
            try:
                listView = self.task_page.wait_element("taskList")
                self.common.taskScreenShot("taskView.jpg")
                taskItems = self.task_page.get_elements("taskItem", 0)
                if (len(taskItems) > 4):
                    self.start_step("滑动每日任务列表")
                    self.common.swipeList(listView)
            except:
                self.common.platformLog("查看任务列表失败")

            #关闭每日任务弹框
            self.task_page.get_element("关闭按钮", 0).click()
        except:
            self.common.platformLog("操作任务场景失败")
        finally:
            self.common.checkPopVisible(self.task_page)
            self.hall_page.wait_element("同步标志")

        time.sleep(5)
        self.common.sendTagBroadcast(EnumSceneName.Task, EnumSceneType.Stop)
示例#5
0
class PerTest_QIPAIHALL_Mall(TestCase):
    '''
    商城操作
    '''
    owner = "JessicZeng"
    status = EnumStatus.Design
    priority = EnumPriority.High
    timeout = 5

    def pre_test(self):
        self.common = Common()
        self.hall_page = Hall_Page()
        self.mall_Page = Mall_Page()

    def run_test(self):
        '''
        测试步骤
        1、大厅点击商城入口
        2、点击第一金条购买item,关闭购买框
        3、滑动金条购买列表
        4、切换到银币购买列表
        5、滑动银币购买列表
        6、切换到道具列表
        7、执行购买第一个道具操作,打开购买弹框后取消购买操作
        8、滑动道具列表
        9、切换到VIP页
        10、返回大厅
        不同类型的商品列表,共用listView和Item
        '''
        self.hall_page.wait_element("同步标志")

        self.start_step("点击大厅商城入口")
        self.common.sendTagBroadcast(EnumSceneName.Mall, EnumSceneType.Start)

        try:
            #点击商城
            self.hall_page.get_element("商城", 0).click()
            time.sleep(2)
            self.mall_Page.wait_element("同步标志")
            self.common.taskScreenShot("openMallPop.jpg")

            #购买金条(选择第一个item)并滑动金条列表
            self.start_step("购买金条")
            self.mall_Page.get_element("item0", 0).click()
            self.mall_Page.wait_element("金条购买框Flag")
            self.common.taskScreenShot("buyGoldPop.jpg")
            self.mall_Page.get_element("金条购买框关闭", 0).click()
            time.sleep(1)
            self.start_step("滑动金条列表")
            self.common.swipeList(self.mall_Page.get_element("物品列表"))

            #切换到银币页并滑动列表
            self.start_step("切换到银币Tab")
            self.mall_Page.get_element("银币Tab", 0).click()
            time.sleep(2)
            self.common.taskScreenShot("silverView.jpg")
            self.start_step("滑动银币列表")
            self.common.swipeList(self.mall_Page.get_element("物品列表"))

            #切换到道具页面,并查看购买道具框,最后滑动列表
            self.start_step("切换到道具Tab")
            self.mall_Page.get_element("道具Tab", 0).click()
            time.sleep(2)
            self.common.taskScreenShot("propView.jpg")
            self.start_step("购买道具")
            self.mall_Page.get_element("item0", 0).click()
            self.mall_Page.wait_element("道具购买框Flag")
            self.common.taskScreenShot("buyPropPop.jpg")
            self.mall_Page.get_element("道具购买框关闭", 0).click()
            time.sleep(1)
            self.start_step("滑动道具列表")
            self.common.swipeList(self.mall_Page.get_element("物品列表"))

            #切换到VIP
            self.start_step("切换到VIPTab")
            self.mall_Page.get_element("VIPTab", 0).click()
            time.sleep(2)
            self.common.taskScreenShot("vipView.jpg")

            #关闭商城弹框
            self.mall_Page.get_element("商城关闭", 0).click()

        except:
            self.common.platformLog("操作商城失败")

        finally:
            self.common.checkPopVisible(self.mall_Page)
            self.hall_page.wait_element("同步标志")

        time.sleep(5)
        self.common.sendTagBroadcast(EnumSceneName.Mall, EnumSceneType.Stop)
示例#6
0
class X0002_LaiziRoom_GamePlay(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()
        self.common.user_money(money=1000)

    def gameplay(self):
        i = 1
        self.common.sendTagBroadcast(EnumSceneName.LaiziRoom, EnumSceneType.Start)
        self.game_page.wait_element("开始").click()
        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
            while self.game_page.element_is_exist("出牌",1)==False:
                list = ["叫地主", "抢地主"]
                for name in list:
                    try:
                        self.game_page.wait_element(name, 0).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("提示",0).click()
                    self.game_page.element_is_exist("出牌",0).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分享"):
                    singleGlobalVar.get("luaDriver").keyevent(4)
                self.game_page.wait_element("继续游戏").click()
            while self.game_page.element_is_exist("去底倍场", 1):
                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("关闭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=1000)
                self.start_step("进去癞子场")
                while self.hall_page.element_is_exist("游戏列表"):
                    elments1 = self.hall_page.get_elements("游戏列表")
                    elments1[1].click()
                    self.game_page.wait_element("切换按钮").click()
                    elments = self.game_page.get_elements("切换玩法")
                    elments[0].click()
                    self.level_page.wait_element("快速开始").click()
                self.start_step("点击初级场房间")
                while self.level_page.element_is_exist("房间列表"):
                    self.level_page.wait_element("房间列表").click()
            while self.game_page.element_is_exist("开始",2):
                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[1].click()
            self.game_page.wait_element("切换按钮").click()
            elments = self.game_page.get_elements("切换玩法")
            elments[0].click()
            # self.level_page.wait_element("快速开始").click()
        self.start_step("点击初级场房间")
        while self.level_page.element_is_exist("房间列表"):
            self.level_page.wait_element("房间列表").click()
        self.gameplay()
        time.sleep(5)
        self.common.sendTagBroadcast(EnumSceneName.LaiziRoom, EnumSceneType.Stop)
示例#7
0
class PerTest_QIPAIHALL_Rank(TestCase):
    '''
    排行榜操作
    '''
    owner = "JessicZeng"
    status = EnumStatus.Design
    priority = EnumPriority.High
    timeout = 5
    global rank_item_count
    rank_item_count = 4

    #一页显示item个数

    def pre_test(self):
        self.common = Common()
        self.hall_page = Hall_Page()
        self.rankPage = Rank_Page()

    def run_test(self):
        '''
        测试步骤
        排行榜内容会重置,当关闭或切换tab后回到默认位置  eg。关闭后再打开默认显示今日内容   切换到新tag后,list index变为0
        操作步骤:
        1、检测同步标志是否出现
        2、点击第一个item,操作加好友   然后关闭用户信息弹框回到排行榜页面
        3、点击第二个item,操作举报(不良头像,然后点击举报按钮)
        4、滑动列表到底
        5、切换到富豪榜,滑动一页数据
        6、切换到昨日排行榜,滑动昨日之富豪榜一页数据
        7、切换tab到昨日收益榜  滑动一页数据
        8、关闭弹框,返回大厅
        '''
        self.hall_page.wait_element("同步标志")

        #点击排行榜大厅入口,进入排行榜
        self.start_step("点击大厅排行榜入口")
        self.common.sendTagBroadcast(EnumSceneName.Rank, EnumSceneType.Start)

        try:
            self.hall_page.get_element("排行榜", 0).click()
            time.sleep(2)
            self.rankPage.wait_element("同步标志")
            self.common.taskScreenShot("openRankPop.jpg")
            headEls = self.rankPage.get_elements("用户头像")
            # 查看排行第一的用户信息,并执行加好友操作
            if len(headEls) >= 1:
                self.start_step("查看rank1的用户信息,并加为好友")
                headEls[0].click()
                self.rankPage.wait_element("用户信息框同步标志")
                self.common.taskScreenShot("playerInfoPop.jpg")
                time.sleep(1)
                self.rankPage.get_element("加好友", 0).click()
                time.sleep(1)
                self.rankPage.get_element("用户信息框关闭按钮", 0).click()

            # 查看排行第二的用户信息,并执行举报操作
            if len(headEls) >= 2:
                self.start_step("查看rank2的用户信息,并执行查看举报弹框然后取消举报")
                headEls[1].click()
                self.rankPage.wait_element("用户信息框同步标志")
                time.sleep(1)
                self.rankPage.get_element("举报", 0).click()
                time.sleep(1)
                self.common.taskScreenShot("reportOtherpop.jpg")
                self.rankPage.wait_element("色情昵称").click()
                time.sleep(1)
                self.rankPage.get_element("取消举报", 0).click()

            # 滑动今日收益排行榜,并滑动到底
            self.start_step("滑动今日收益榜,并滑动到底")
            self.common.taskScreenShot("todayIncomeRank.jpg")
            self.swipeListView(True)

            # 切换到昨日富豪榜,并将列表滑动一页
            self.start_step("滑动一页昨日富豪榜")
            self.rankPage.get_element("日期", 0).click()
            time.sleep(1)
            self.common.taskScreenShot("yesterdayRegalRank.jpg")
            # 当文字发生改变时,表示切换成功
            while self.rankPage.get_element("日期文字").get_attribute(
                    "text") == '昨日':
                None
                self.swipeListView(False)

            # 返回大厅
            self.rankPage.get_element("返回大厅", 0).click()
        except:
            self.common.platformLog("排行榜操作失败")
        finally:
            self.common.checkPopVisible(self.rankPage)
            self.hall_page.wait_element("同步标志")

        time.sleep(5)
        self.common.sendTagBroadcast(EnumSceneName.Rank, EnumSceneType.Stop)

    def swipeListView(self, loop):
        '''
        滑动指定列表
        :param listName:  列表元素名
        :param itemName:  列表item元素名
        :param loop:  是否循环滑动到底
        :return:
        '''
        listView = None
        itemViews = None
        try:
            listView = self.rankPage.get_element("排行榜列表")
            # itemViews = self.rankPage.get_elements("排行榜item")
        except:
            self.common.platformLog("排行榜指定列表元素不存在,结束列表滑动测试")
            return

        cnt = 1
        while cnt < 10:
            # for item in itemViews:
            #     Common.printStr("item x y:",item.location["x"]," ",item.location["y"])
            # self.com.swipeList(listView)
            # if loop == False:
            #     break
            # itemViews = self.rankPage.get_elements("排行榜item")
            self.common.swipeList(listView)
            if loop == False:
                break
            cnt = cnt + 1
            time.sleep(0.2)
        time.sleep(1)
示例#8
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('大厅头像')
示例#9
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)
示例#10
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('大厅头像')
示例#11
0
class PerTest_QIPAIHALL_Userinfo(TestCase):
    '''
    玩家个人信息框操作
    '''
    owner = "JessicZeng"
    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()

    def run_test(self):
        '''
        操作步骤:
        1、点击大厅个人信息框入口
        2、修改昵称
        3、修改性别
        4、修改城市
        5、查看VIP特权,然后返回个人信息框
        6、切换账号(可能造成前后两次结果有差异主要是切换账号后可能有签到框)
        7、结束测试
        :return:
        '''
        self.hall_page.wait_element("同步标志")
        self.start_step("点击大厅玩家信息框入口")
        self.common.sendTagBroadcast(EnumSceneName.UserInfo,EnumSceneType.Start)
        try:
            self.hall_page.wait_element("头像").click()
            time.sleep(2)
            self.personinfo_page.wait_element("同步标志")
            time.sleep(1)
            self.common.taskScreenShot('openUserInfo_pop.jpg')

            #设置用户昵称,修改后点击其他地方来保存修改
            self.start_step("修改昵称")
            nickName = self.common.random_str(6)
            self.personinfo_page.get_element("设置用户名",0).send_keys(nickName)
            self.personinfo_page.get_element("同步标志",0).click()
            self.common.taskScreenShot('modifyNick.jpg')

            #修改玩家性别,女改男,男改女  get_attribute('selected')
            self.start_step("修改性别")
            enGirl = self.personinfo_page.get_element("女")
            if (enGirl.get_attribute('selected') == "true"):
                self.common.platformLog("点击性别男")
                self.personinfo_page.get_element("男").click()
            else:
                self.common.platformLog("点击性别女")
                self.personinfo_page.get_element("女").click()
            self.common.taskScreenShot('modifySex.jpg')

            #修改城市,海南和四川来回切换  若当前为四川则切换为海南  反之亦然
            self.start_step("修改城市")
            cityNameStr = self.personinfo_page.get_element("城市").get_attribute('text')
            self.personinfo_page.wait_element("城市").click()
            element1 = self.personinfo_page.get_element("海南")  # 海南
            element2 = self.personinfo_page.get_element("四川")  # 四川
            if cityNameStr.find('四川') != -1 :
                self.common.moveElement(element1, element2)
            else:
                self.common.moveElement(element2, element1)
            time.sleep(2)
            self.personinfo_page.wait_element("同步标志").click()
            self.common.taskScreenShot('modifyCity.jpg')

            #查看VIP特权
            self.start_step("查看VIP特权")
            self.personinfo_page.get_element("了解VIP特权",0).click()
            time.sleep(2)
            self.common.taskScreenShot('VIPPrivilege.jpg')
            try:
                self.personinfo_page.wait_element("特权同步标志")
                self.personinfo_page.wait_element("返回个人资料").click()
            except:
                self.common.platformLog("VIP特权页面显示失败,结束玩家信息框测试")

            self.personinfo_page.get_element("关闭",0).click()
            #切换账号,用已有账号登录  登录成功后会直接返回大厅并切换账号
            # time.sleep(2)
            # self.start_step("切换账号")
            # try:
            #     self.personinfo_page.get_element("切换账号").click()
            #     self.personinfo_page.wait_element("继续登录").click()
            #     self.personinfo_page.wait_element("登录框title")
            #     self.personinfo_page.wait_element("账号").send_keys("18676676262")
            #     self.personinfo_page.wait_element("密码").send_keys("zrf.870208")
            #     self.personinfo_page.wait_element("确认登录").click()
            #     self.hall_page.wait_element("同步标志")
            # except:
            #     print "切换账号失败,直接退回到大厅"
            #     while (self.personinfo_page.is_exist("同步标志")):
            #         self.com.closePop()
            # finally:
            #     self.com.closeActivity()
        except:
            self.common.platformLog("操作个人信息框失败")
        finally:
            self.common.checkPopVisible(self.personinfo_page)
            self.hall_page.wait_element("同步标志")

        time.sleep(5)
        self.common.sendTagBroadcast(EnumSceneName.UserInfo, EnumSceneType.Stop)
示例#12
0
class X0001_EnterHall(TestCase):
    '''
    点击登录按钮,转圈,转圈后流畅显示,无明显卡顿
    '''
    owner = "LucyLiu"
    status = EnumStatus.Design
    priority = EnumPriority.High
    timeout = 5

    def pre_test(self):
        self.common = Common()
        self.hall_page = Hall_Page()
        self.game_page = Game_Page()
        time.sleep(10)
        self.game_page.to_hall_page("女孩")

    def run_test(self):
        time.sleep(10)
        # self.hall_page.wait_element("同步标志")
        self.common.taskScreenShot("login.jpg")
        self.start_step("进入登陆页面")
        if self.hall_page.element_is_exist("暂不认证"):
            self.hall_page.wait_element("暂不认证").click()
        if self.hall_page.element_is_exist("内网"):
            self.hall_page.wait_element("内网").click()
        self.common.sendTagBroadcast(EnumSceneName.EnterHall, EnumSceneType.Start)
        while not self.hall_page.element_is_exist("大厅头像"):
            while self.hall_page.element_is_exist("游客登录"):
                try:
                    self.hall_page.wait_element("游客登录").click()
                except:
                    print "未找到此按钮"
        if self.hall_page.element_is_exist("暂不认证"):
            self.hall_page.wait_element("暂不认证").click()
        if self.hall_page.element_is_exist("进入游戏",2):
            self.hall_page.wait_element("进入游戏").click()
        self.game_page.to_hall_page("大厅头像")
        self.hall_page.wait_element("大厅头像",60)
        self.start_step("德州小测验")
        while (self.game_page.element_is_exist("go",2)):
            driver = singleGlobalVar.get("luaDriver")
            driver.keyevent(4)
            if self.hall_page.element_is_exist("取消"):
                self.hall_page.wait_element("取消").click()
        self.common.sendTagBroadcast(EnumSceneName.EnterHall, EnumSceneType.Stop)
        self.start_step("获取mid")
        self.hall_page.wait_element("大厅头像").click()
        mid = self.hall_page.wait_element("mid").get_attribute('text')
        self.common.set_config_value("casecfg", "mid", str(mid))
        self.start_step("查看是否需要添加金币")
        money = self.hall_page.wait_element("金币数").get_attribute('text')
        money = money.replace(',','')
        print money
        if int(money) < 10000:
            Interface.add_Money(mid,10000)
        self.hall_page.wait_element("关闭").click()

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