예제 #1
0
 def runTest(self):
     try:
         exec(self._code["code"], self._code["ns"])
     except Exception as err:
         tb = traceback.format_exc()
         log("Final Error", tb)
         six.reraise(*sys.exc_info())
예제 #2
0
 def runTest(self):
     try:
         # 调用脚本中的runCase方法并传递scope供脚本使用
         self.runCase(self.scope)
     except Exception as err:
         tb = traceback.format_exc()
         log("Final Error", tb)
         six.reraise(*sys.exc_info())
예제 #3
0
파일: runer.py 프로젝트: hancf6433/TFmall
 def wrapper(*args,**kwargs):
     try:
         f(*args,**kwargs)
     except:
         tb = traceback.format_exc()
         log("Final Error", tb)
         raise
     finally:
         try:
             snapshot(msg="Final Snapshot")
         except:
             log("无最终截图")
예제 #4
0
    def runTest(self):
        scriptpath, pyfilename = script_dir_name(self.args.script)
        pyfilepath = os.path.join(scriptpath, pyfilename)
        pyfilepath = os.path.abspath(pyfilepath)
        self.scope["__file__"] = pyfilepath
        with open(pyfilepath, 'r', encoding="utf8") as f:
            code = f.read()
        pyfilepath = pyfilepath.encode(sys.getfilesystemencoding())

        try:
            exec(compile(code.encode("utf-8"), pyfilepath, 'exec'), self.scope)
        except Exception as err:
            log(err, desc="Final Error", snapshot=True)
            six.reraise(*sys.exc_info())
예제 #5
0
def test_startgame(login):
    """启动游戏"""
    myGameStart = GameStart()
    myGameStart.stopGame()
    sleep(1)
    myGameStart.starGame()
    # assert_equal(myGameStart.isStarGame, True, "启动游戏{0}".format(myGameStart.GameStart_info))
    myGameLoaded = GameLoaded()
    actualValue = myGameLoaded.mainprocess(login=login)
    if float(myGameLoaded.GameLoaded_info["loadtime"]) > 50:
        log(Exception("load游戏时间大于30s!加载时间为:{0}".format(
            myGameLoaded.GameLoaded_info["loadtime"])),
            snapshot=True)
    assert_equal(actualValue, True,
                 "启动游戏{0}".format(myGameLoaded.GameLoaded_info))
    sleep(3)
예제 #6
0
파일: runner.py 프로젝트: zzwcj2012/Airtest
    def runTest(self):
        scriptpath = self.args.script
        pyfilename = os.path.basename(scriptpath).replace(
            self.SCRIPTEXT, ".py")
        pyfilepath = os.path.join(scriptpath, pyfilename)
        pyfilepath = os.path.abspath(pyfilepath)
        self.scope["__file__"] = pyfilepath
        with open(pyfilepath, 'r', encoding="utf8") as f:
            code = f.read()
        pyfilepath = pyfilepath.encode(sys.getfilesystemencoding())

        try:
            exec(compile(code.encode("utf-8"), pyfilepath, 'exec'), self.scope)
        except Exception as err:
            tb = traceback.format_exc()
            log("Final Error", tb)
            six.reraise(*sys.exc_info())
예제 #7
0
    def runTestPyTest(self):
        '''运行Py文件用例'''
        #scriptpath, pyfilename = script_dir_name(self.args.script)
        #pyfilepath = os.path.join(scriptpath, pyfilename)
        pyfilepath = os.path.abspath(self.args.script)

        self.scope["__file__"] = pyfilepath
        with open(pyfilepath, 'r', encoding="utf8") as f:
            code = f.read()
        pyfilepath = pyfilepath.encode(sys.getfilesystemencoding())

        try:
            exec(compile(code.encode("utf-8"), pyfilepath, 'exec'), self.scope)
        except Exception as err:
            tb = traceback.format_exc()
            log("Final Error", tb)
            six.reraise(*sys.exc_info())
예제 #8
0
파일: SettingPage.py 프로젝트: xin7c/Yavin
 def goto_network_ping(self):
     """
     ping网络检测 -> Network Diagnosis
     :return:
     """
     self.poco(text=self.page_ele_loc("TEXT_NETWORK_DIAGNOSIS")).click()
     try:
         assert_equal(self.poco(text="Upload diagnosis report").exists(),
                      True,
                      msg='Upload diagnosis report 按钮出现')
         log('网络检测页面截图',
             timestamp=time.time(),
             desc='网络检测页面截图',
             snapshot=True)
     except AssertionError as e:
         log(e,
             timestamp=time.time(),
             desc='Upload diagnosis report 按钮没有出现',
             snapshot=True)
     return self
예제 #9
0
 def runTest(self):
     # 参数传入的脚本路径
     scriptpath = self.args.script
     # 分割路径最后的名字,替换.air为.py,也就是传入‘d:/aaa/bbb.air’,pyfilename就为bbb.py
     pyfilename = os.path.basename(scriptpath).replace(self.SCRIPTEXT, ".py")
     # 再组装py文件的路径,d:/aaa/bbb.air/bbb.py,看过air脚本文件就知道,这才是脚本代码,其他是图片
     pyfilepath = os.path.join(scriptpath, pyfilename)
     pyfilepath = os.path.abspath(pyfilepath)
     self.scope["__file__"] = pyfilepath
     # 读进来
     with open(pyfilepath, 'r', encoding="utf8") as f:
         code = f.read()
     pyfilepath = pyfilepath.encode(sys.getfilesystemencoding())
     # 运行读进来的脚本
     try:
         exec(compile(code.encode("utf-8"), pyfilepath, 'exec'), self.scope)
     except Exception as err:
         tb = traceback.format_exc()
         log("Final Error", tb)
         six.reraise(*sys.exc_info())
예제 #10
0
    def runTest(self):
        scriptpath, pyfilename = script_dir_name(self.args.script)
        pyfilepath = os.path.join(scriptpath, pyfilename)
        pyfilepath = os.path.abspath(pyfilepath)
        self.scope["__file__"] = pyfilepath
        with open(pyfilepath, 'r', encoding="utf8") as f:
            code = f.read()
        pyfilepath = pyfilepath.encode(sys.getfilesystemencoding())

        print('<gql> runner>runTest>pyfilepath: ', pyfilepath)
        #print('<gql> runner>runTest>code: ',code)
        #print('<gql> runner>runTest>self.scope: ',self.scope)
        #         log('<gql> runner>runTest>pyfilepath: ',pyfilepath)
        #         log('<gql> runner>runTest>code: ',code)
        #         log('<gql> runner>runTest>self.scope: ',self.scope)

        try:
            exec(compile(code.encode("utf-8"), pyfilepath, 'exec'), self.scope)
        except Exception as err:
            tb = traceback.format_exc()
            log("Final Error", tb)
            six.reraise(*sys.exc_info())
예제 #11
0
 def discoverPopup(self):  # 积分弹框
     """大厅弹框检查"""
     self.Popuplist = []
     poplist = MyData.popup_dir[0]
     havePopup = True
     self.UIAlterPoP()
     COM_utilities.clock()  # 插入计时器
     while havePopup:
         print("进入弹框判断")
         mytime = float(COM_utilities.clock("stop"))
         if mytime > 60:
             log(Exception("弹框处理超时...."), snapshot=True)
             raise Exception
         if self.poco("PopupPanel").children():
             print("进入PopupPanel弹框判断")
             child = self.poco("PopupPanel").child(nameMatches="^UI.*",
                                                   visible=True)
             for list in child:
                 listname = list.get_name()
                 print("listname:", listname)
                 for k in poplist:
                     if listname == k["args"][0]:
                         if listname == "UIGiftPopup":
                             if self.find_try("UIGiftPopup",
                                              "推送礼包",
                                              0.2,
                                              tryTime=1):
                                 self.findClick_try("GiftShake",
                                                    "GiftBag3",
                                                    "礼物",
                                                    0.2,
                                                    tryTime=1,
                                                    sleeptime=5)
                                 self.findClick_try("UIBagItemReward",
                                                    "BtnStore",
                                                    "会员卡",
                                                    0.2,
                                                    tryTime=1,
                                                    sleeptime=1)
                                 self.findClick_try("UIBagItemReward",
                                                    "BtnRead",
                                                    "背包道具推送",
                                                    0.2,
                                                    tryTime=1,
                                                    sleeptime=1)
                         else:
                             self.findClick_try(k["args"][0],
                                                k["args"][1],
                                                description=k["func_name"],
                                                waitTime=1,
                                                tryTime=1,
                                                sleeptime=2)
         elif self.poco("PopUpPanel").children():
             print("进入PopUpPanel弹框判断")
             try:
                 child1 = self.poco("PopUpPanel").child(nameMatches="^UI.*",
                                                        visible=True)
                 for list in child1:
                     listname = list.get_name()
                     print("listname:", listname)
                     for k in poplist:
                         if listname == k["args"][0]:
                             if listname == "UIGiftPopup":
                                 if self.find_try("UIGiftPopup",
                                                  "推送礼包",
                                                  0.2,
                                                  tryTime=1):
                                     self.findClick_try("GiftShake",
                                                        "GiftBag3",
                                                        "礼物",
                                                        0.2,
                                                        tryTime=1,
                                                        sleeptime=5)
                                     self.findClick_try("UIBagItemReward",
                                                        "BtnStore",
                                                        "会员卡",
                                                        0.2,
                                                        tryTime=1,
                                                        sleeptime=1)
                                     self.findClick_try("UIBagItemReward",
                                                        "BtnRead",
                                                        "背包道具推送",
                                                        0.2,
                                                        tryTime=1,
                                                        sleeptime=1)
                             else:
                                 self.findClick_try(
                                     k["args"][0],
                                     k["args"][1],
                                     description=k["func_name"],
                                     waitTime=1,
                                     tryTime=1,
                                     sleeptime=0.5)
             except:
                 print("PopUpPanel非点击弹框")
         else:
             print("判断当前无弹框")
             havePopup = False
         self.discoverPopup_info["弹框列表:"] = FindObject.Popuplist
     return True