Esempio n. 1
0
    def run(self):
        try:
            list = []
            # self.runaction.setDisabled(True)
            # self.runmian = Runexe(self.widget.idlist)
            # self.runmian.sinOut.connect(self.finsh)
            # for x in self.widget.idlist:
            #     x = Runexe(x)
            #     list.append(x)
            # for x in list:
            #     x.start()
            #     time.sleep(5)
            # logger.info("测试程序正在启动......")
            for x in self.widget.idlist:
                x = Runexe(x)
                x.start()
                time.sleep(5)
                logger.info("测试程序正在启动......")

        except:
            z = QMessageBox()
            z.warning(self, "异常", "请终止异常操作")
            logger.error("请终止异常操作,要弄死程序了")
        finally:
            x.quit()
Esempio n. 2
0
    def screenshots(self, start, end, box=None):
        x = min(start[0], end[0])
        y = min(start[1], end[1])
        width = abs(end[0] - start[0])
        height = abs(end[1] - start[1])
        self.box = (x, y, x + width, y + height)
        try:
            if self.address is None:
                fileName = QFileDialog.getSaveFileName(self, '保存图片', '.',
                                                       ".png;;.jpg")
                if fileName[0]:
                    im = ImageGrab.grab(self.box)
                    im.save(fileName[0] + fileName[1])
                    self.close()
            else:
                im = ImageGrab.grab(self.box)
                im.save(self.address)
                # im.show()
                self.close()
        except:
            logger.error("已取消截图")
        finally:
            self.close()

            CASEDATA[self.id] = self.box
            return self.box
Esempio n. 3
0
 def Confirmexit(self):
     try:
         self.temp.Setconfig(location=PATHDATA["config"],
                             outconfdata=PATHDATA)
         self.temp.Setconfig(location="TestCase/id_png.ini",
                             outconfdata=CASEDATA)
         sleep(0.5)
         self.close()
     except:
         logger.error("配置数据异常无法保存")
Esempio n. 4
0
    def SingleRun(self):
        try:
            _id = set(self.idlist)
            _casedata=CaseData(PATHDATA.get("data"))
            _dir =_casedata._dirset()
            extension=_casedata.key_value()[1]
            report = _casedata.key_value()[2]
            _cha = _id - (_id & _dir)
            if CentralView.c**t == 0:
                if _cha:
                    reply = QMessageBox.warning(self, '当前路径下缺失用例名称为:%s' % _cha.pop(),
                                                "当前测试用例数据不完整将无法批量执行是否不再提示?", QMessageBox.Yes |
                                                QMessageBox.No, QMessageBox.No)

                    if reply == QMessageBox.Yes:
                        CentralView.c**t = 1
                    else:
                        CentralView.c**t = 0
                else:
                    pass
            else:
                pass
            send = self.sender()
            run_idcase = self.__translate(send,2).get(str(send), str(send))
            if str(send) == run_idcase:
                logger.error("当前是异常数据项:%s" % run_idcase)
            else:
                PS=Photoshop(PATHDATA.get("data"))
                time.sleep(0.5)
                self.exe = Runexe(run_idcase)
                self.exe.start()
                time.sleep(3)
                logger.debug("正在准备截图存放路径为:%s"%report.get(run_idcase))
                if report.get(run_idcase)is None:
                    logger.error("无法在对该测试用例进行截图:%s"%report.get(run_idcase))
                else:
                    PS.Conditions_for_screenshots(address=report.get(run_idcase),box=CASEDATA.get(run_idcase))
                    # PS.grab(report.get(run_idcase))
                RT=PS.alignment_section(extension.get(run_idcase),report.get(run_idcase))
                if RT:
                    self.reportdict[run_idcase] = "通过"
                else:
                    self.reportdict[run_idcase] = "不通过"
            self.id=run_idcase
            # self.shortcutpng.connect(self.shortcutprintscreen)
            return self.id
        except:
            logger.warning("数据无效无法启动")
        finally:
            listi=[]
            for x in self.idlist:
                self.updatetemp[x][2]=self.reportdict[x]
                listi=listi+self.updatetemp[x]
            self.datalist=self.templist + listi
Esempio n. 5
0
 def grab(self, CRimg):
     try:
         # shellTray = win32gui.FindWindow("Shell_TrayWnd", None)
         # win32gui.ShowWindow(shellTray, 0)
         im = ImageGrab.grab()
         im.getbbox()
         im.save(CRimg)
     except:
         logger.error("截图异常")
     finally:
         # win32gui.ShowWindow(shellTray, 1)
         self.sourcedata = CaseData(self.sourcedata)
Esempio n. 6
0
    def printscreen(self):
        try:
            send = self.sender()
            extension_idcase1 = self.__translate(send, 3).get((str(send) + "]"), str(send))
            if extension_idcase1 == str(send):
                logger.warning("当前是异常数据项:%s" % extension_idcase1)
            else:
                _casedata = CaseData(PATHDATA.get("data"))
                extension = _casedata.key_value()[1]
                # self.Screenshotsignalhide.emit()
                self.screenshot = Photoshop(PATHDATA.get("data"),address=extension.get(extension_idcase1),
                                            id=extension_idcase1)
                self.screenshot.showFullScreen()
                logger.info("截图完毕,路径下已存在:%s" % extension.get(extension_idcase1))

        except:
            logger.error("无法截图")
        finally:
            # self.Screenshotsignalshow.emit()
            pass
Esempio n. 7
0
    def closeEvent(self, event):
        reply = QMessageBox.question(self, '提示?', "你确定要退出么?",
                                     QMessageBox.Yes | QMessageBox.No,
                                     QMessageBox.No)

        if reply == QMessageBox.Yes:
            try:
                if hasattr(self, "dialog1"):
                    if self.dialog1.isVisible() is True:
                        self.dialog1.destroy()
                    else:
                        pass
                else:
                    pass
                if self.check_exsit("app.exe") is True:
                    os.system('TASKKILL /F /IM app.exe')
                else:
                    pass
            except OSError:
                logger.error("查杀异常")
            finally:
                event.accept()
        else:
            event.ignore()