예제 #1
0
 def input_date(self, date):
     if int(date) > 32 or int(date) < 1:
         raise Exception("请输入正确的日期值")
     flag = False
     for i in range(len(self.find_elements(*(By.XPATH, '/html/body/div')))):
         if flag == True:
             break
         if ('el-date-picker' in self.getElementAttribute('class', *(By.XPATH, '/html/body/div[{}]'.format(i + 1)))) and \
                 ('display: none' not in self.getElementAttribute('style', *(By.XPATH, '/html/body/div[{}]'.format(i + 1)))):
             for x in range(6):
                 if flag == True:
                     break
                 for y in range(7):
                     if self.get_elementText(
                             *
                         (By.XPATH,
                          '/html/body/div[{}]/div[1]/div/div[2]/table[1]/tbody/tr[{}]/td[{}]/div/span'
                          .format(i + 1, x + 2, y + 1))) == date:
                         self.click(*(
                             By.XPATH,
                             '/html/body/div[{}]/div[1]/div/div[2]/table[1]/tbody/tr[{}]/td[{}]/div/span'
                             .format(i + 1, x + 2, y + 1)))
                         flag = True
                         break
                     else:
                         pass
     if flag != True:
         logger.error('日期框选择日期失败,请检查配置')
         raise Exception('日期框选择日期失败,请检查配置')
     else:
         logger.info("当前日期框填写的日期值为:{}号".format(date))
예제 #2
0
 def click_saveButton(self):
     self.click(*self._saveButton)
     logger.info('点击保存按钮')
     if self.getToastBoxText() == '保存成功':
         logger.info('修改信息保存成功')
     else:
         logger.error('保存失败')
         raise Exception('保存修改失败')
예제 #3
0
 def click_selectResult(self):
     try:
         sleep(1)
         self.click(*self._selectResult)
         logger.info("点击查询结果")
     except:
         logger.error("没有找到查询结果,--- try again ---")
         sleep(1)
         self.click(*self._selectResult)
예제 #4
0
    def get(self, ax_id):
        mongo = MongoDB()
        test_instance = mongo.db.test_instance.find_one({"ax_id": ax_id})
        if not test_instance:
            # synchronize it lively
            response = self.send_ax_request(AX_SERVER + "test/" + ax_id, "GET")
            doc = self.json_decode(response)
            if not doc.has_key("ax_id"):
                doc["ax_id"] = doc["identity"]["ax_id"]
            my_test_instance = doc
            mongo.db.test_instance.insert(my_test_instance)
            test_instance = mongo.db.test_instance.find_one({"ax_id": ax_id})

        _id = test_instance.pop("_id")
        synchronize_flag = True
        now = time.time()
        if test_instance.has_key("update_time"):
            last_update = int(test_instance["update_time"])
            if now - last_update < 3600 * 24:
                # Need to force-sychronize after 1 days
                synchronize_flag = False

        if synchronize_flag:
            # start to synchronize
            try:
                response = self.send_ax_request(AX_SERVER + "test/" + ax_id, "GET")
                test_instance_attributes = self.json_decode(response)

                for p in test_instance_attributes["parameters"]["parameter"]:
                    if p["type"] in ("single_select", "multiple_select"):
                        # find the valid selection
                        r = self.send_ax_request(AX_SERVER + "parameter/" + p["ax_id"], "GET")
                        d = self.json_decode(r)
                        p["validation"] = d["validation"]

                test_instance_attributes["update_time"] = now
                test_instance.update(test_instance_attributes)
                mongo.db.test_instance.update({"_id": _id}, test_instance)

            except Exception as e:
                logger.error(e)

        test_instance = mongo.db.test_instance.find_one({"ax_id": ax_id}, projection={"_id": False})
        self.write(self.json_encode(test_instance))
예제 #5
0
    def open_boe(self, boeType, boeName):
        logger.info("打开的单据类型为:{} ,选择的单据业务类型为: {}".format(boeType, boeName))

        flag = False
        for i in range(
                len(
                    self.find_elements(*(
                        By.XPATH,
                        '//*[@id="app"]/section/main/div/div/div[2]/div[3]/div[3]/div/div[2]/div'
                    )))):
            if flag == True:
                break
            if self.get_elementText(
                    *
                (By.XPATH,
                 '//*[@id="app"]/section/main/div/div/div[2]/div[3]/div[3]/div/div[2]/div[{}]/div[1]/span'
                 .format(i + 1))) == boeType:
                for j in range(
                        len(
                            self.find_elements(*(
                                By.XPATH,
                                '//*[@id="app"]/section/main/div/div/div[2]/div[3]/div[3]/div/div[2]/div[{}]/div[2]/div'
                                .format(i + 1))))):
                    if self.get_elementText(
                            *
                        (By.XPATH,
                         '//*[@id="app"]/section/main/div/div/div[2]/div[3]/div[3]/div/div[2]/div[{}]/div[2]/div[{}]/div[2]'
                         .format(i + 1, j + 1))) == boeName:
                        self.moveToclick(*(
                            By.XPATH,
                            '//*[@id="app"]/section/main/div/div/div[2]/div[3]/div[3]/div/div[2]/div[{}]/div[2]/div[{}]'
                            .format(i + 1, j + 1)))
                        flag = True
                        break
                    else:
                        pass
            else:
                pass
        logger.info("是否正常打开单据: {}".format(flag))
        if flag != True:
            logger.error('Exception: Don\'t find Boe, please check config')
            raise Exception('Don\'t find Boe, please check config')
예제 #6
0
 def get(self, testset_ax_id=-1):
     if not self.current_user:
         self.redirect("/login/")
     else:
         mongo = MongoDB()
         test_instances = mongo.db.test_instance.find(projection={"_id": False})
         if int(testset_ax_id) > 0:
             try:
                 testset = self.send_ax_request("testset/" + testset_ax_id, "GET")
                 self.render("testset_builder.html", test_instances=test_instances, testset=testset)
             except Exception as e:
                 logger.error(str(e))
                 self.flash("error", "Failed to load testset.")
                 self.render(
                     "error.html",
                     error="Failed to load testset. Ordinarily refresh could resolve the problem. Reason - "
                     + str(e),
                 )
         else:
             self.render("testset_builder.html", test_instances=test_instances, testset="")
예제 #7
0
 def select_option(self, option, *loc) -> None:
     """
     说明:
         系统编码下拉选择框选择
     :param option:  下拉框选择项
     :param *loc:    定位元素
     :return: None
     """
     self.click(*loc)
     sleep(1)
     for i in range(30):
         if i == 29:
             logger.error('没有找到对应配置项,请检查配置')
             raise Exception('没有找到对应配置项,请检查配置')
         if self.get_elementText(*(loc[0],
                                   (loc[1] +
                                    '.option.{}').format(i))) == option:
             self.moveToclick(*(loc[0], (loc[1] + '.option.{}').format(i)))
             break
     logger.info('选择的数据为:{}'.format(option))
예제 #8
0
    def boeBusinessApprove(self):
        try:

            self._easIndexPage.click_myWaitApprove()
            sleep(1)
            self._easIndexPage.click_moreButton()

            sleep(1)
            self._easIndexPage.input_boeNo(self.boeNum)
            sleep(1)
            self._easIndexPage.click_boeNoSelectButton()

            sleep(1)
            status = self._easIndexPage.selectResultIsOrNotBusiness(
                self.boeNum)
            if status == True:
                pass
            else:
                logger.error("boeNum do not exist")
                raise Exception("boeNum do not exist")

            sleep(1)
            self._easIndexPage.click_boeBusinessApprove()
            sleep(1)
            self._easIndexPage.click_boeBusinessTipConfirm()

            sleep(1)
            if self._easIndexPage.getToastBoxText() == '操作成功':
                content = '审批成功'
                logger.info("审批状态为:{}".format(content))
                self.login.driver.quit()
                return content
            else:
                content = '审批失败'
                logger.info("审批状态为:{}".format(content))
                self.login.driver.quit()
                return content

        except Exception as e:
            logger.error("业务审批出现异常,异常信息为:{}".format(type(e)))
            self.login.driver.quit()
예제 #9
0
    def getTickets(self, date, personType, personName, fromCity, toCity, siteType, ticketFee, isReplace):
        if self._pageType == 'boeInvoicePage':
            year, month, day = date.split('-')[0], date.split('-')[1], date.split('-')[2]

            self._oeInvoiceCommon.open_addInvoiceWindow(self.invoiceType)
            try:
                self._oeInvoiceCommon.select_itemtripDate(year, month, day)
            except Exception as e:
                logger.error("出现异常,异常信息为:{}".format(type(e)))
                self._oeInvoiceCommon.open_addInvoiceWindow(self.invoiceType)
                self._oeInvoiceCommon.select_itemtripDate(year, month, day)
            self._oeInvoiceCommon.select_itempersonnelAttribution(personType)
            self._oeInvoiceCommon.input_itempassengerName(personName)
            self._oeInvoiceCommon.input_itemstartOffCityName(fromCity)
            self._oeInvoiceCommon.input_itemarriveCityName(toCity)
            self._oeInvoiceCommon.select_itemseatLevel(siteType)
            self._oeInvoiceCommon.input_itemfee(ticketFee)
            self._oeInvoiceCommon.select_itemisReplacementTicket(isReplace)
            self._oeInvoiceCommon.click_invoiceSubmitButton()
            sleep(2)
            logger.info('新增火车票成功')
예제 #10
0
 def send_swarm_request(self,url,method="GET",retry=1,content_type="application/json",**kwargs):
     import tornado.httpclient as http
     from tornado.httputil import HTTPHeaders
     from tornado.httpclient import HTTPError
     if not url.startswith(SWARM_API_URL_BASE):
         url=SWARM_API_URL_BASE+url
     http_client = http.HTTPClient()
     header =HTTPHeaders()
     header.add("content_type",content_type)
     if hasattr(self,"cookie"):
         #logged in
         header.add("Cookie",self.cookie)
     else:
         #not logged-in. readonly
         header.add("Cookie",self.readonly_cookie)
     http_request = http.HTTPRequest(url,method=method,headers=header,**kwargs)
     logger.info("Sending request to SWARM url: %s, method: %s"%(url,method))
     if retry<0:
         retry=1
     while retry>0:
         retry-=1
         response=http_client.fetch(http_request,raise_error=False)
         logger.info (http_request.method+" | "+http_request.url+" | "+str(response.code))
         if response.code<300:
             http_client.close()
             if "Set-Cookie" in response.headers.keys():
                 cookie=response.headers["Set-Cookie"]
                 logger.info("Set Coockie: "+ cookie)
                 self.cookie=cookie
             return response.body
         elif response.code==599:
             logger.info("Timeout, retry chance:"+str(retry))
             logger.error(response.body)
             if retry>0:
                 continue
             else:
                 raise HTTPError(response.code,message=response.body,response=response)
         else:
             raise HTTPError(response.code,message=response.body,response=response)
예제 #11
0
    def test_newCostEstimateBoe(self):
        try:

            logger.info(" ----- 单据提交流程开始 ----- ")

            with allure.step("点击选择采购付款页面"):
                self.newCostEstimateBoePage.selectTabType('采购付款')
            with allure.step("进入成本暂估单(新)单据提交页面"):
                self.newCostEstimateBoePage.boeRntry('成本暂估(新)')

            global boeNum
            boeNum = self.newCostEstimateBoePage.getBoeNum()

            with allure.step("选择业务类型"):
                self.newCostEstimateBoePage.input_operationType('UI通用')
            with allure.step("输入备注"):
                self.newCostEstimateBoePage.input_boeAbstract('测试成本暂估单(新)')

            with allure.step("选择项目"):
                self.newCostEstimateBoePage.input_project('UI项目')
            with allure.step("选择供应商"):
                self.newCostEstimateBoePage.selectVendor('UIGYS',
                                                         vendorName='UI供应商')
            # with allure.step("选择关联合同"):
            #     self.newCostEstimateBoePage.selectContract('hc00000020')
            with allure.step("选择成本中心"):
                self.newCostEstimateBoePage.selectCc('UICBZX', ccName='UI成本中心')

            acceptanceNo = record.readDataFromRecord(
                type='acceptanceLedgerData')['acceptanceNo']

            with allure.step("关联验收单"):
                self.newCostEstimateBoePage.relateAcceptanceLedger(
                    acceptanceNo)

            with allure.step("点击单据提交"):
                self.newCostEstimateBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.newCostEstimateBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.newCostEstimateBoePage.click_more()
                self.newCostEstimateBoePage.input_boeNumQuery(boeNum)
                self.newCostEstimateBoePage.click_queryButton()

            with allure.step("断言结果:{}".format(
                    self.newCostEstimateBoePage.checkBoeNumExistIsOrNot(
                        boeNum))):
                assert self.newCostEstimateBoePage.checkBoeNumExistIsOrNot(
                    boeNum) == True

        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.newCostEstimateBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.newCostEstimateBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.newCostEstimateBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            assert 1 == 1
    def sharingCenterApproveChuShen(self, modify=False, **kwargs):

        self._handleTimer = HandleTimer('共享中心', '共享从中台同步单据', self.login.driver)
        self._handleTimer.runTimer()

        self._myAuditListPage.gotoAuditAdjustDirectorPage()
        self._auditAdjustDirectorPage.input_selectBoeNum(self.boeNum)
        self._auditAdjustDirectorPage.click_selectButton()

        try:
            self._auditAdjustDirectorPage.click_selectResult()
        except:
            logger.info('没有找到单据,{}'.format(self.boeNum))
            logger.info('----- Try again -----')
            self._handleTimer = HandleTimer('共享中心', '共享从中台同步单据',
                                            self.login.driver)
            self._handleTimer.runTimer()
            self._auditAdjustDirectorPage.input_selectBoeNum(self.boeNum)
            self._auditAdjustDirectorPage.click_selectButton()
            self._auditAdjustDirectorPage.click_selectResult()

        self._auditAdjustDirectorPage.click_taskTakeToBack()
        self._auditAdjustDirectorPage.click_selectResult()

        # 分配到组
        try:
            self._auditAdjustDirectorPage.choiceGroup(
                config.getUrlDict()['Approval']['approvalGroupC'])
        except:
            sleep(1)
            self._auditAdjustDirectorPage.click_selectResult()
            sleep(1)
            self._auditAdjustDirectorPage.choiceGroup(
                config.getUrlDict()['Approval']['approvalGroupC'])

        # 分配到人
        self._auditAdjustDirectorPage.click_selectResult()
        try:
            self._auditAdjustDirectorPage.choiceOperatorUser(
                config.getUrlDict()['Approval']['approvalUserC'])
        except:
            self._auditAdjustDirectorPage.click_selectResult()
            self._auditAdjustDirectorPage.choiceOperatorUser(
                config.getUrlDict()['Approval']['approvalUserC'])

        self._auditAdjustDirectorPage.gotoAuditList()
        self._myAuditListPage.input_boeNumQuery(self.boeNum)
        self._myAuditListPage.click_boeNumQueryButton()

        try:
            self._myAuditListPage.getIntoBoe()
        except:
            sleep(1)
            self._myAuditListPage.getIntoBoe()
        self._boeCommon.switchWindow()

        parameterList = [i for i in kwargs.keys()]
        logger.info('参数列表为:{}'.format(parameterList))

        if modify == True:

            sleep(3)
            if 'checkCode' in parameterList:
                self._boeCommon.input_dtosCheckCode(kwargs['checkCode'])

            if 'invoiceTypeCode' in parameterList:
                self._boeCommon.input_dtosInvoiceTypeCode(
                    kwargs['invoiceTypeCode'])

            if 'invoiceNo' in parameterList:
                self._boeCommon.input_dtosInvoiceNo(kwargs['invoiceNo'])

            if 'invoiceCode' in parameterList:
                self._boeCommon.input_dtosInvoiceCode(kwargs['invoiceCode'])

            if 'invoiceDate' in parameterList:
                self._boeCommon.input_dtosInvoiceDate(kwargs['invoiceDate'])

            if 'invoiceFee' in parameterList:
                self._boeCommon.input_dtosInvoiceFee(kwargs['invoiceFee'])

            if 'invoiceTax' in parameterList:
                self._boeCommon.input_dtosInvoiceTax(kwargs['invoiceTax'])

            if 'invoiceRemark' in parameterList:
                self._boeCommon.input_dtosInvoiceRemark(
                    kwargs['invoiceRemark'])

            self._boeCommon.click_saveButton()

        self._boeCommon.click_accountMessage()
        self._boeCommon.click_approveButton()

        try:
            if self._boeCommon.getToastBoxText() != '审批成功':
                logger.info('弹窗信息为:{}'.format(
                    self._boeCommon.getToastBoxText()))
                raise Exception('审批不成功')
            else:
                logger.info('弹窗信息为:{}'.format(
                    self._boeCommon.getToastBoxText()))
                logger.info('单据财务审批成功')
        except:
            sleep(1)
            if self._boeCommon.getToastBoxText() != '审批成功':
                logger.info('弹窗信息为:{}'.format(
                    self._boeCommon.getToastBoxText()))
                try:
                    logger.error(self._boeCommon.getBoxMessage())
                except:
                    pass
                finally:
                    raise Exception('审批不成功')
            else:
                logger.info('弹窗信息为:{}'.format(
                    self._boeCommon.getToastBoxText()))
                logger.info('单据财务审批成功')

        self._boeCommon.switchWindow()
    def test_newPurchasingBillBoe(self):

        try:

            logger.info(" ----- 单据提交流程开始 ----- ")

            with allure.step("点击选择采购付款页面"):
                self.newPurchasingBillBoePage.selectTabType('采购付款')
            with allure.step("进入采购报账单单据提交页面"):
                self.newPurchasingBillBoePage.boeRntry('采购报账')

            global boeNum
            boeNum = self.newPurchasingBillBoePage.getBoeNum()

            with allure.step("选择业务类型"):
                self.newPurchasingBillBoePage.input_operationType('UI通用')
            with allure.step("输入备注"):
                self.newPurchasingBillBoePage.input_boeAbstract('测试采购报账单')

            with allure.step("选择供应商"):
                self.newPurchasingBillBoePage.selectVendor('UIGYS',
                                                           vendorName='UI供应商')
            # with allure.step("选择关联合同"):
            #     self.newPurchasingBillBoePage.selectContract('hc00000022')
            with allure.step("输入项目"):
                self.newPurchasingBillBoePage.input_project('UI项目')
            with allure.step("选择成本中心"):
                self.newPurchasingBillBoePage.selectExpenseDept(
                    'UIDP', deptName='UI部门')

            # with allure.step("建立关联"):
            #     self.newPurchasingBillBoePage.click_makeRelated()
            #     self.newPurchasingBillBoePage.relateAcceptancesheetAndInvoice('ysd005', '88800001')

            with allure.step("输入支付金额"):
                self.newPurchasingBillBoePage.selectAccountReceivable('质保金付款')

            with allure.step("点击单据提交"):
                self.newPurchasingBillBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.newPurchasingBillBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.newPurchasingBillBoePage.click_more()
                self.newPurchasingBillBoePage.input_boeNumQuery(boeNum)
                self.newPurchasingBillBoePage.click_queryButton()

            with allure.step("断言结果:{}".format(
                    self.newPurchasingBillBoePage.checkBoeNumExistIsOrNot(
                        boeNum))):
                assert self.newPurchasingBillBoePage.checkBoeNumExistIsOrNot(
                    boeNum) == True

        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.newPurchasingBillBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.newPurchasingBillBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.newPurchasingBillBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            assert 1 == 1
예제 #14
0
def traffic_event_reform(path):
    data = read_anomaly_data(path)

    anomaly_info_list = []
    unique_prot_list = list(set(data.prot))
    for prot in unique_prot_list:
        print 'reforming ' + prot
        prot_data = data[data.prot == prot]
        unique_attack_channel = list(
            set(zip(prot_data.ip, prot_data.dest_port)))
        bar = Bar('Loading',
                  fill='@',
                  suffix='%(percent)d%% %(avg).3fs',
                  max=len(unique_attack_channel))
        print 'number of unique attack channels ' + str(
            len(unique_attack_channel))
        for ip, dest_port in unique_attack_channel:
            logger.debug(ip + ' : ' + prot + ' -> ' + str(dest_port))
            ip_data = prot_data[(prot_data.ip == ip)
                                & (prot_data.dest_port == dest_port)]
            if ip_data.shape[0] == 0:
                logger.error('weird emtpy ip_data')
                raise
            #ip_data = ip_data.resample(RESAMPLE_FREQ,on='time').apply(aggregate_func)
            ip_data.groupby(pd.Grouper(freq='1Min',
                                       key='time')).apply(agg_multi_func)
            #ip_data = ip_data[ip_data['raw_values'].isnull()==False]
            ip_data.sort_index(inplace=True)

            time_index = 1
            for _, row in ip_data.iterrows():
                #logger.debug(str(row))
                if str(row.anomaly_score) == 'NaT':
                    continue
                anomaly_info = {}
                anomaly_info['A'] = round(row.anomaly_score, 3)
                anomaly_info['C'] = ['Traffic', row.direction]
                anomaly_info['S'] = [
                    ip, row.prot,
                    str(dest_port),
                    list(row.cor_ip_list.split('#')), row.abnormal_event_type,
                    row.gmm_params, row.evt_value
                ]
                cur_time = row.time
                end_time = cur_time + TIME_DELTA
                if row.abnormal_event_type == 'ND_score':
                    ND_duration = datetime.timedelta(
                        seconds=float(row.raw_values))
                    end_time = cur_time + ND_duration
                    #end_time = cur_time + TIME_DELTA
                else:
                    end_time = cur_time + TIME_DELTA

                anomaly_info['T'] = [[
                    cur_time.day, cur_time.hour, cur_time.minute,
                    cur_time.second
                ],
                                     [
                                         end_time.day, end_time.hour,
                                         end_time.minute, end_time.second
                                     ]]
                anomaly_info['V'] = row.raw_values
                anomaly_info['TimeIndex'] = time_index
                time_index += 1
                anomaly_info_list.append(anomaly_info)
            bar.next()
        bar.finish()
    logger.info('anomaly info for analysis, list length : ' +
                str(len(anomaly_info_list)))
    return anomaly_info_list
예제 #15
0
    def test_newPurchasePrepaymentBoe(self):

        try:

            logger.info(" ----- 单据提交流程开始 ----- ")

            with allure.step("点击选择采购付款页面"):
                self.newPurchasePrepaymentBoePage.selectTabType('采购付款')
            with allure.step("进入采购预付单单据提交页面"):
                self.newPurchasePrepaymentBoePage.boeRntry('采购预付')

            global boeNum
            boeNum = self.newPurchasePrepaymentBoePage.getBoeNum()

            with allure.step("选择业务类型"):
                self.newPurchasePrepaymentBoePage.input_operationType('UI通用')
            with allure.step("输入备注"):
                self.newPurchasePrepaymentBoePage.input_boeAbstract('测试采购预付单')

            with allure.step("选择供应商"):
                self.newPurchasePrepaymentBoePage.selectVendor(
                    'UIGYS', vendorName='UI供应商')
            # with allure.step("选择关联合同"):
            #     self.newPurchasePrepaymentBoePage.selectContract('123456789')

            with allure.step("输入采购订单"):
                self.newPurchasePrepaymentBoePage.input_loanOrderNumber(
                    'UI' +
                    "".join(random.choice(string.digits) for _ in range(6)))
            with allure.step("选择预付类型"):
                self.newPurchasePrepaymentBoePage.input_loanOperationSubType(
                    'UI通用01')
            with allure.step("输入预付金额"):
                self.newPurchasePrepaymentBoePage.input_loanExpenseAmount(
                    '100.00')

            with allure.step("选择支付方式"):
                self.newPurchasePrepaymentBoePage.selectPaymentMethod('UI挂账')

            with allure.step("点击单据提交"):
                self.newPurchasePrepaymentBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.newPurchasePrepaymentBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.newPurchasePrepaymentBoePage.click_more()
                self.newPurchasePrepaymentBoePage.input_boeNumQuery(boeNum)
                self.newPurchasePrepaymentBoePage.click_queryButton()

            with allure.step("断言结果:{}".format(
                    self.newPurchasePrepaymentBoePage.checkBoeNumExistIsOrNot(
                        boeNum))):
                assert self.newPurchasePrepaymentBoePage.checkBoeNumExistIsOrNot(
                    boeNum) == True

        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.newPurchasePrepaymentBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.newPurchasePrepaymentBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.newPurchasePrepaymentBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)

            boeNumPath = os.path.join(
                os.path.dirname(os.path.realpath(__file__)), 'boeNum.json')
            writeBoeNum(boeNumPath, boeNum)

            assert 1 == 1
    def test_newIncomeStatementBoe(self, newIncomeStatementBoe_testdata):
        try:

            logger.info(" ----- 单据提交流程开始 ----- ")

            with allure.step("点击选择收入收款页面"):
                self.newIncomeStatementBoePage.selectTabType('收入收款')
            with allure.step("进入收入报账单单据提交页面"):
                self.newIncomeStatementBoePage.boeRntry('收入报账')

            global boeNum
            boeNum = self.newIncomeStatementBoePage.getBoeNum()

            with allure.step("选择业务类型"):
                self.newIncomeStatementBoePage.input_operationType(
                    newIncomeStatementBoe_testdata['operationType'])
            with allure.step("输入备注"):
                self.newIncomeStatementBoePage.input_boeAbstract(
                    newIncomeStatementBoe_testdata['boeAbstract'])

            with allure.step("选择客户"):
                self.newIncomeStatementBoePage.selectVendor(
                    newIncomeStatementBoe_testdata['vendor']['vendorCode'],
                    vendorName=newIncomeStatementBoe_testdata['vendor']
                    ['vendorName'])
            # with allure.step("选择关联合同"):
            #     self.newIncomeStatementBoePage.selectContract(newIncomeStatementBoe_testdata['contract'])
            with allure.step("输入订单编号"):
                self.newIncomeStatementBoePage.input_orderNumber(
                    newIncomeStatementBoe_testdata['orderNumber'])
            with allure.step("选择业务类型"):
                self.newIncomeStatementBoePage.input_operationSubType(
                    newIncomeStatementBoe_testdata['operationSubType'])
            with allure.step("选择利润中心"):
                self.newIncomeStatementBoePage.selectExpenseDept(
                    newIncomeStatementBoe_testdata['expenseDept']['deptCode'],
                    deptName=newIncomeStatementBoe_testdata['expenseDept']
                    ['deptName'])
            with allure.step("输入金额"):
                self.newIncomeStatementBoePage.input_incomeDetailExpenseAmount(
                    newIncomeStatementBoe_testdata['expenseAmount'])
            with allure.step("输入税额"):
                self.newIncomeStatementBoePage.input_incomeDetailTaxAmount(
                    newIncomeStatementBoe_testdata['taxAmount'])

            with allure.step("点击单据提交"):
                self.newIncomeStatementBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.newIncomeStatementBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.newIncomeStatementBoePage.click_more()
                self.newIncomeStatementBoePage.input_boeNumQuery(boeNum)
                self.newIncomeStatementBoePage.click_queryButton()

            with allure.step("断言结果:{}".format(
                    self.newIncomeStatementBoePage.checkBoeNumExistIsOrNot(
                        boeNum))):
                assert self.newIncomeStatementBoePage.checkBoeNumExistIsOrNot(
                    boeNum) == True

            logger.info(" ----- 单据提交流程结束 ----- ")

        except Exception as e:

            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.newIncomeStatementBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.newIncomeStatementBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.newIncomeStatementBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            assert 1 == 1
예제 #17
0
    def test_costEstimateBoe(self):
        try:

            logger.info(" ----- 单据提交流程开始 ----- ")

            with allure.step("点击选择采购付款页面"):
                self.costEstimateBoePage.selectTabType('采购付款')
            with allure.step("进入成本暂估单(旧)单据提交页面"):
                self.costEstimateBoePage.boeRntry('成本暂估(旧)')

            global boeNum
            boeNum = self.costEstimateBoePage.getBoeNum()

            with allure.step("选择业务类型"):
                self.costEstimateBoePage.input_operationType('UI通用')
            with allure.step("输入备注"):
                self.costEstimateBoePage.input_boeAbstract('测试成本暂估单(旧)')

            with allure.step("选择供应商"):
                self.costEstimateBoePage.selectVendor('UIGYS',
                                                      vendorName='UI供应商')
            # with allure.step("选择关联合同"):
            #     self.costEstimateBoePage.selectContract('hc00000020')

            with allure.step("输入订单编号"):
                self.costEstimateBoePage.input_costOrderNumber('hcOrder001')
            with allure.step("选择业务小类"):
                self.costEstimateBoePage.input_costOperationSubType('UI通用01')
            with allure.step("输入总金额"):
                self.costEstimateBoePage.input_costExpenseAmount('100.00')
            with allure.step("选择责任部门"):
                self.costEstimateBoePage.selectCc('UIDP', 'UI部门')
            with allure.step("选择项目"):
                self.costEstimateBoePage.input_costProject('UI项目')
            with allure.step("输入备注"):
                self.costEstimateBoePage.input_costRemark('测试成本暂估单(旧)')

            with allure.step("点击单据提交"):
                self.costEstimateBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.costEstimateBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.costEstimateBoePage.click_more()
                self.costEstimateBoePage.input_boeNumQuery(boeNum)
                self.costEstimateBoePage.click_queryButton()

            with allure.step("断言结果:{}".format(
                    self.costEstimateBoePage.checkBoeNumExistIsOrNot(boeNum))):
                assert self.costEstimateBoePage.checkBoeNumExistIsOrNot(
                    boeNum) == True

        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.costEstimateBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.costEstimateBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.costEstimateBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            assert 1 == 1
예제 #18
0
    def test_employeeLoad(self, employeeLoadBoe_testdata):
        try:
            logger.info(" ----- 单据流程开始 ----- ")
            with allure.step("打开借款还款单据选择页面"):
                sleep(3)
                self.employeeLoansBoePage.open_boeBorrow()
            with allure.step("打开的单据类型为:{} ,选择的单据业务类型为: {}".format(
                    '员工借款单', employeeLoadBoe_testdata['operationType'])):
                try:
                    self.employeeLoansBoePage.open_boe(
                        '员工借款单', employeeLoadBoe_testdata['operationType'])
                except:
                    sleep(3)
                    logger.error(" Don't find Boe, Try again")
                    self.employeeLoansBoePage.open_boe(
                        '员工借款单', employeeLoadBoe_testdata['operationType'])

            global boeNum
            boeNum = self.employeeLoansBoePage.getBoeNum()

            with allure.step("输入业务类型"):
                self.employeeLoansBoePage.input_operationType(
                    employeeLoadBoe_testdata['operationType'])
            with allure.step("输入备注"):
                self.employeeLoansBoePage.input_boeAbstract(
                    employeeLoadBoe_testdata['boeAbstract'])

            with allure.step("输入业务类型"):
                self.employeeLoansBoePage.input_operationSubTypeId(
                    employeeLoadBoe_testdata['operationSubTypeId'])
            with allure.step("输入总金额"):
                self.employeeLoansBoePage.input_expenseAmount(
                    employeeLoadBoe_testdata['expenseAmount'])
            with allure.step("输入项目"):
                self.employeeLoansBoePage.input_projectId(
                    employeeLoadBoe_testdata['projectName'])

            with allure.step("点击单据提交"):
                self.employeeLoansBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.employeeLoansBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.employeeLoansBoePage.click_myBoeList()
                self.employeeLoansBoePage.click_moreButton()
                self.employeeLoansBoePage.input_boeNo(boeNum)
                self.employeeLoansBoePage.click_boeNoSelectButton()
                status = self.employeeLoansBoePage.selectResultIsOrNot(boeNum)

            logger.info(" ----- 单据提交流程结束 ----- ")
            assert status == True
        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.employeeLoansBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.employeeLoansBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.employeeLoansBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)

            boeNumPath = os.path.join(
                os.path.dirname(os.path.realpath(__file__)), 'boeNum.json')
            writeBoeNum(boeNumPath, boeNum)

            assert 1 == 1
    def test_newPurchasingAdvicePaymentBoe(self):

        try:

            logger.info(" ----- 单据提交流程开始 ----- ")

            with allure.step("点击选择采购付款页面"):
                self.newPurchasingAdvicePaymentBoePage.selectTabType('采购付款')
            with allure.step("进入采购付款单单据提交页面"):
                self.newPurchasingAdvicePaymentBoePage.boeRntry('采购付款')

            global boeNum
            boeNum = self.newPurchasingAdvicePaymentBoePage.getBoeNum()

            with allure.step("选择业务类型"):
                self.newPurchasingAdvicePaymentBoePage.input_operationType(
                    'UI通用')
            with allure.step("输入备注"):
                self.newPurchasingAdvicePaymentBoePage.input_boeAbstract(
                    '测试采购付款单')

            with allure.step("选择供应商"):
                self.newPurchasingAdvicePaymentBoePage.selectVendor(
                    'UIGYS', vendorName='UI供应商')
            # with allure.step("选择关联合同"):
            #     self.newPurchasingAdvicePaymentBoePage.selectContract('hc00000021')

            with allure.step("关联挂账款"):
                self.newPurchasingAdvicePaymentBoePage.selectAccountReceivable(
                    self.prepaidBoeNum)

            with allure.step("点击单据提交"):
                self.newPurchasingAdvicePaymentBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.newPurchasingAdvicePaymentBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.newPurchasingAdvicePaymentBoePage.click_more()
                self.newPurchasingAdvicePaymentBoePage.input_boeNumQuery(
                    boeNum)
                self.newPurchasingAdvicePaymentBoePage.click_queryButton()

            with allure.step("断言结果:{}".format(
                    self.newPurchasingAdvicePaymentBoePage.
                    checkBoeNumExistIsOrNot(boeNum))):
                assert self.newPurchasingAdvicePaymentBoePage.checkBoeNumExistIsOrNot(
                    boeNum) == True

        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.newPurchasingAdvicePaymentBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.newPurchasingAdvicePaymentBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.newPurchasingAdvicePaymentBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            assert 1 == 1
예제 #20
0
def event_to_visual_form(data):
    unique_ip_list = pd.unique(data.ip)
    anomaly_info_list = []
    bar = Bar('Loading',
              fill='@',
              suffix='%(percent)d%% %(avg).3fs',
              max=len(unique_ip_list))
    for ip in unique_ip_list:
        logger.debug(ip)

        node_id_abbr = 'Net_' + ip
        node_id_fullname = 'Traffic Measurement for Host ' + ip
        node_index = 'TD_' + str(node_id_2_index_map[node_id_abbr])
        categories = {'category': 'Traffic', 'variableName': 'flow_ANF'}
        time_series = []

        ip_data = data[(data.ip == ip)]
        unique_item_list = pd.unique(zip(ip_data.prot, ip_data.dest_port))
        for prot, dest_port in unique_item_list:
            port_data = ip_data[(ip_data.prot == prot)
                                & (ip_data.dest_port == dest_port)]
            if port_data.shape[0] == 0:
                logger.error('weird emtpy ip_data')
                raise
            port_data.groupby(pd.Grouper(freq='1Min',
                                         key='time')).apply(agg_multi_func)
            port_data.sort_values(by=['time'], inplace=True)

            for _, row in port_data.iterrows():
                if str(row.anomaly_score) == 'NaT':
                    continue
                cur_time = row.time
                if row.abnormal_event_type == 'ND_score':
                    ND_duration = datetime.timedelta(
                        seconds=float(row.raw_values))
                    next_time = cur_time + ND_duration
                #next_time = cur_time + TIME_DELTA
                else:
                    next_time = cur_time + TIME_DELTA
                start_time = [
                    cur_time.day, cur_time.hour, cur_time.minute,
                    cur_time.second
                ]
                end_time = [
                    next_time.day, next_time.hour, next_time.minute,
                    next_time.second
                ]
                start_time_str = ':'.join([str(e) for e in start_time])
                end_time_str = ':'.join([str(e) for e in end_time])

                node_port = ':' + str(row.dest_port)
                if row.dest_port == 'None':
                    node_port = ''
                node_port = row.prot + str(node_port)
                time_series.append({
                    'weight': round(row.anomaly_score, 3),
                    'T_start': start_time_str,
                    'T_end': end_time_str,
                    #'SpaceFloor': space[0],
                    #'SpaceZone': space[1],
                    #'SpaceRoom': space[2],
                    'Variable': row.raw_values,
                    'port': node_port,
                    'event_type': row.abnormal_event_type,
                    'evt_value': row.evt_value,
                    'direction': row.direction,
                    'gmm_params': row.gmm_params
                })
        anomaly_info = {
            '_id': node_index,
            'dataType': DATA_TYPE,
            'nodeFullName': node_id_fullname,
            'nodeName': node_id_abbr,
            'nodeIndex': node_index,
            'categories': categories,
            'timeSeries': time_series
        }
        anomaly_info_list.append(anomaly_info)
        bar.next()
    bar.finish()
    return anomaly_info_list
예제 #21
0
    def test_newDailyExpense(self, newDailyExpenseBoe_testdata):
        try:
            logger.info(" ----- 单据流程开始 ----- ")
            with allure.step("打开费用报销单据选择页面"):
                sleep(3)
                self.newDailyExpenseBoePage.open_boeReimburse()
            with allure.step("打开的单据类型为:{} ,选择的单据业务类型为: {}".format('日常费用报账单', newDailyExpenseBoe_testdata['operationType'])):
                try:
                    self.newDailyExpenseBoePage.open_boe('日常费用报账单', newDailyExpenseBoe_testdata['operationType'])
                except:
                    sleep(3)
                    logger.error(" Don't find Boe, Try again")
                    self.newDailyExpenseBoePage.open_boe('日常费用报账单', newDailyExpenseBoe_testdata['operationType'])

            global boeNum
            boeNum = self.newDailyExpenseBoePage.getBoeNum()

            with allure.step("输入业务类型"):
                self.newDailyExpenseBoePage.input_operationType(newDailyExpenseBoe_testdata['operationType'])
            with allure.step("输入备注"):
                self.newDailyExpenseBoePage.input_boeAbstract(newDailyExpenseBoe_testdata['boeAbstract'])

            # with allure.step("选择关联发票"):
            #     self.newDailyExpenseBoePage.selectRelatedInvoice(newDailyExpenseBoe_testdata['relatedInvoice'])


            with allure.step("点击新增发票"):
                self.newDailyExpenseBoePage.click_addInvoiceButton()
                self.newDailyExpenseBoePage.click_invoiceType()
                invoiceFactory.get_invoice(self.login.driver, '增值税普通发票', 'boeInvoicePage').getTickets(
                    date = datetime.datetime.now().strftime('%Y-%m-%d'),
                    invoiceNo = ''.join(random.choice(string.digits) for _ in range(12)),
                    invoiceCode = ''.join(random.choice(string.digits) for _ in range(8)),
                    feeTotal = '100.00',
                    tax = '0.00',
                    checkCode = '123456')
            with allure.step("输入业务类型"):
                try:
                    self.newDailyExpenseBoePage.selectOperationSubType(newDailyExpenseBoe_testdata['operationSubType'])
                except:
                    sleep(1)
                    self.newDailyExpenseBoePage.selectOperationSubType(newDailyExpenseBoe_testdata['operationSubType'])

            with allure.step("选择部门"):
                self.newDailyExpenseBoePage.selectDepartment(newDailyExpenseBoe_testdata['deptCode'], newDailyExpenseBoe_testdata['deptName'])
            with allure.step("输入项目"):
                self.newDailyExpenseBoePage.input_projectId(newDailyExpenseBoe_testdata['projectName'])

            with allure.step("点击单据提交"):
                self.newDailyExpenseBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.newDailyExpenseBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.newDailyExpenseBoePage.click_myBoeList()
                self.newDailyExpenseBoePage.click_moreButton()
                self.newDailyExpenseBoePage.input_boeNo(boeNum)
                self.newDailyExpenseBoePage.click_boeNoSelectButton()
                status = self.newDailyExpenseBoePage.selectResultIsOrNot(boeNum)

            logger.info(" ----- 单据提交流程结束 ----- ")
            assert status == True

        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.newDailyExpenseBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow), name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.newDailyExpenseBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.newDailyExpenseBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow), name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            assert 1 == 1
예제 #22
0
    def test_applyTravel(self, applyTravelBoe_testdata):
        try:
            logger.info(" ----- 单据流程开始 ----- ")
            with allure.step("打开事项申请单据选择页面"):
                sleep(3)
                self.applyTravelBoePage.open_boeApply()
            with allure.step("打开的单据类型为:{} ,选择的单据业务类型为: {}".format('差旅申请单', applyTravelBoe_testdata['operationType'])):
                try:
                    self.applyTravelBoePage.open_boe('差旅申请单', applyTravelBoe_testdata['operationType'])
                except:
                    logger.error(" Don't find Boe, Try again")
                    sleep(3)
                    self.comFeeApplyBoePage.open_boe('通用费用申请单', applyTravelBoe_testdata['operationType'])

            global boeNum
            boeNum = self.applyTravelBoePage.getBoeNum()

            with allure.step("输入业务类型"):
                self.applyTravelBoePage.input_operationType(applyTravelBoe_testdata['operationType'])
            with allure.step("输入备注"):
                self.applyTravelBoePage.input_boeAbstract(applyTravelBoe_testdata['boeAbstract'])
            with allure.step("输入金额"):
                self.applyTravelBoePage.input_applyAmount(applyTravelBoe_testdata['applyAmount'])

            with allure.step("输入开始时间:{}".format(applyTravelBoe_testdata['beginDateStr'])):
                self.applyTravelBoePage.input_beginDateStr(applyTravelBoe_testdata['beginDateStr'])
            with allure.step("输入结束时间:{}".format(applyTravelBoe_testdata['endDateStr'])):
                self.applyTravelBoePage.input_endDateStr(applyTravelBoe_testdata['endDateStr'])
            with allure.step("输入出差任务"):
                self.applyTravelBoePage.select_travelTask(applyTravelBoe_testdata['travelTask'])
            with allure.step("输入出发城市"):
                self.applyTravelBoePage.input_fromCity(applyTravelBoe_testdata['fromCity'])
            with allure.step("输入到达城市"):
                self.applyTravelBoePage.input_toCity(applyTravelBoe_testdata['toCity'])
            with allure.step("输入交通工具"):
                self.applyTravelBoePage.select_transportation(applyTravelBoe_testdata['transportation'])


            with allure.step("点击单据提交"):
                self.applyTravelBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.applyTravelBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.applyTravelBoePage.click_myBoeList()
                self.applyTravelBoePage.click_moreButton()
                self.applyTravelBoePage.input_boeNo(boeNum)
                self.applyTravelBoePage.click_boeNoSelectButton()
                status = self.applyTravelBoePage.selectResultIsOrNot(boeNum)

            logger.info(" ----- 单据提交流程结束 ----- ")
            assert status == True

        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.applyTravelBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow), name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.applyTravelBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.applyTravelBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow), name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            assert 1 == 1
예제 #23
0
    def test_employeeRepayment(self, employeeRepaymentBoe_testdata):
        try:
            logger.info(" ----- 单据流程开始 ----- ")
            with allure.step("打开借款还款单据选择页面"):
                sleep(3)
                self.employeeRepaymentBoePage.open_boeBorrow()
            with allure.step("打开的单据类型为:{} ,选择的单据业务类型为: {}".format(
                    '员工还款单', employeeRepaymentBoe_testdata['operationType'])):
                try:
                    self.employeeRepaymentBoePage.open_boe(
                        '员工还款单',
                        employeeRepaymentBoe_testdata['operationType'])
                except:
                    sleep(3)
                    logger.error(" Don't find Boe, Try again")
                    self.employeeRepaymentBoePage.open_boe(
                        '员工还款单',
                        employeeRepaymentBoe_testdata['operationType'])

            global boeNum
            boeNum = self.employeeRepaymentBoePage.getBoeNum()

            self.boeFee = self.employeeRepaymentBoePage.selectWriteOffBoe(
                self.loadBoeNum)

            with allure.step("输入业务类型"):
                self.employeeRepaymentBoePage.input_operationType(
                    employeeRepaymentBoe_testdata['operationType'])
            with allure.step("输入备注"):
                self.employeeRepaymentBoePage.input_boeAbstract(
                    employeeRepaymentBoe_testdata['boeAbstract'])

            with allure.step("输入还款方式"):
                self.employeeRepaymentBoePage.selectReplaymentType(
                    employeeRepaymentBoe_testdata['operationSubType'])
            with allure.step("输入还款金额"):
                # self.employeeRepaymentBoePage.input_expenseAmount(self.boeFee)
                self.employeeRepaymentBoePage.input_expenseAmount('100..00')
            with allure.step("输入收款账户"):
                self.employeeRepaymentBoePage.selectCollectionAccount(
                    employeeRepaymentBoe_testdata['favoriteId'])
            with allure.step("输入还款日期"):
                self.employeeRepaymentBoePage.selectLoanRepaymentDate(
                    datetime.datetime.now().strftime("%Y-%m-%d"))
            with allure.step("输入还困说明"):
                self.employeeRepaymentBoePage.input_remark(
                    employeeRepaymentBoe_testdata['remark'])

            with allure.step("点击单据提交"):
                self.employeeRepaymentBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.employeeRepaymentBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.employeeRepaymentBoePage.click_myBoeList()
                self.employeeRepaymentBoePage.click_moreButton()
                self.employeeRepaymentBoePage.input_boeNo(boeNum)
                self.employeeRepaymentBoePage.click_boeNoSelectButton()
                status = self.employeeRepaymentBoePage.selectResultIsOrNot(
                    boeNum)

            logger.info(" ----- 单据提交流程结束 ----- ")
            assert status == True
        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.employeeRepaymentBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.employeeRepaymentBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.employeeRepaymentBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            assert 1 == 1
    def test_newMultiDomesticTravel(self, newMultiDomesticTravelBoe_testdata):
        try:
            logger.info(" ----- 单据流程开始 ----- ")
            with allure.step("打开费用报销单据选择页面"):
                sleep(3)
                self.newMultiDomesticTravelBoePage.open_boeReimburse()
            with allure.step("打开的单据类型为:{} ,选择的单据业务类型为: {}".format('多人差旅报账单', newMultiDomesticTravelBoe_testdata['operationType'])):
                try:
                    self.newMultiDomesticTravelBoePage.open_boe('多人差旅报账单', newMultiDomesticTravelBoe_testdata['operationType'])
                except:
                    sleep(3)
                    logger.error(" Don't find Boe, Try again")
                    self.newMultiDomesticTravelBoePage.open_boe('多人差旅报账单', newMultiDomesticTravelBoe_testdata['operationType'])

            global boeNum
            boeNum = self.newMultiDomesticTravelBoePage.getBoeNum()

            with allure.step("输入业务类型"):
                self.newMultiDomesticTravelBoePage.input_operationType(newMultiDomesticTravelBoe_testdata['operationType'])
            with allure.step("输入备注"):
                self.newMultiDomesticTravelBoePage.input_boeAbstract(newMultiDomesticTravelBoe_testdata['boeAbstract'])

            with allure.step("增加出行人员"):
                self.newMultiDomesticTravelBoePage.add_travelers(newMultiDomesticTravelBoe_testdata['travelers'])
            with allure.step("输入项目"):
                self.newMultiDomesticTravelBoePage.select_projectId(newMultiDomesticTravelBoe_testdata['projectName'])

            self.newMultiDomesticTravelBoePage.clearPersonCard()

            with allure.step("新增发票操作"):
                self.newMultiDomesticTravelBoePage.click_addInvoiceButton()
                self.newMultiDomesticTravelBoePage.click_invoiceType()
                # 差旅火车票新增
                invoiceFactory.get_invoice(self.login.driver, '火车票', 'boeInvoicePage').getTickets(
                    # datetime.datetime.now().strftime("%Y-%m-%d")
                    '2021-02-22',
                    '内部人员',
                    'UI01',
                    '长沙',
                    '杭州',
                    '二等座(高铁/动车)',
                    '500.00',
                    '否')

                self.newMultiDomesticTravelBoePage.click_addInvoiceButton()
                self.newMultiDomesticTravelBoePage.click_invoiceType()
                # 差旅火车票新增
                invoiceFactory.get_invoice(self.login.driver, '火车票', 'boeInvoicePage').getTickets(
                    # datetime.datetime.now().strftime("%Y-%m-%d")
                    '2021-02-22',
                    '内部人员',
                    'UI02',
                    '长沙',
                    '杭州',
                    '二等座(高铁/动车)',
                    '500.00',
                    '否')

            # self.newMultiDomesticTravelBoePage.click_addInvoiceButton()
            # self.newMultiDomesticTravelBoePage.click_invoiceType()
            # invoiceFactory.get_invoice(self.login.driver, '增值税普通发票', 'boeInvoicePage').getTickets(
            #     '2021-1-27', '811000000002', '81100002', '100.10', '0.10', '123456')

            with allure.step("点击单据提交"):
                self.newMultiDomesticTravelBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.newMultiDomesticTravelBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.newMultiDomesticTravelBoePage.click_myBoeList()
                self.newMultiDomesticTravelBoePage.click_moreButton()
                self.newMultiDomesticTravelBoePage.input_boeNo(boeNum)
                self.newMultiDomesticTravelBoePage.click_boeNoSelectButton()
                status = self.newMultiDomesticTravelBoePage.selectResultIsOrNot(boeNum)

            logger.info(" ----- 单据提交流程结束 ----- ")
            assert status == True

        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.newMultiDomesticTravelBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow), name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.newMultiDomesticTravelBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.newMultiDomesticTravelBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow), name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            assert 1 == 1
예제 #25
0
    def test_login(self, publciLoginPage_testdata):
        ''' --------------------测试登陆时不同场景-------------------- '''

        logger.info("测试用例名字为:{}".format(publciLoginPage_testdata["casename"]))

        allure.title(publciLoginPage_testdata["casename"])
        with allure.step("第一步,登录页面初始化"):
            self.publicloginpage.refresh()

        with allure.step("第二步,输入账号/密码"):
            self.publicloginpage.input_account(publciLoginPage_testdata["account"])
            logger.debug("输入账户为:{}".format(publciLoginPage_testdata["account"]))
            self.publicloginpage.input_password(publciLoginPage_testdata["password"])
            logger.debug("输入密码为:{}".format(publciLoginPage_testdata["password"]))

        with allure.step("第三步,点击登录按钮"):
            self.publicloginpage.click_loginbutton()

        with allure.step("第四步,判断断言信息"):

            try:

                if (publciLoginPage_testdata["casename"] == '账号密码不匹配') or (publciLoginPage_testdata["casename"] =='当前登录用户名或密码错误'):
                    WebDriverWait(self.publicloginpage.driver, 5).until(
                        EC.visibility_of_element_located(self.publicloginpage.getMessageBox()))
                    msg = self.publicloginpage.get_errortext()
                    assert (publciLoginPage_testdata["casename"] in msg)

                elif publciLoginPage_testdata["casename"] == '请输入账户名称':
                    WebDriverWait(self.publicloginpage.driver, 5).until(
                        EC.text_to_be_present_in_element(self.publicloginpage.getAccountInputErrorBox(),publciLoginPage_testdata["casename"]))
                    msg = self.publicloginpage.get_accounterrortext()
                    assert publciLoginPage_testdata["casename"] == msg

                elif publciLoginPage_testdata["casename"] == '请输入密码':
                    WebDriverWait(self.publicloginpage.driver, 5).until(
                        EC.text_to_be_present_in_element(self.publicloginpage.getPasswordInputErrorBox(),publciLoginPage_testdata["casename"]))
                    msg = self.publicloginpage.get_passworderrortext()
                    assert publciLoginPage_testdata["casename"] == msg

                elif publciLoginPage_testdata["casename"] == '登陆成功':
                    WebDriverWait(self.publicloginpage.driver, 5).until(
                        EC.visibility_of_element_located(self.publicloginpage.getIntoButton()))
                    self.publicloginpage.get_into()
                    self.publicloginpage.driver.refresh()
                    assert 1 == 1

            except Exception as e:

                logger.error("出现异常,异常信息为:{}".format(type(e)))
                code = 'wrong'
                timeNow = getNowTime()
                self.publicloginpage.screenshot(code, timeNow)
                allure.attach.file(getPicturePath(code,timeNow),name=timeNow + code + "screenshot",
                                   attachment_type=allure.attachment_type.PNG)
                assert 1 == 0
            else:

                logger.info("测试用例执行成功")
                code = 'success'
                timeNow = getNowTime()
                self.publicloginpage.screenshot(code, timeNow)
                allure.attach.file(getPicturePath(code, timeNow), name=timeNow + code + "screenshot",
                                   attachment_type=allure.attachment_type.PNG)
    def test_newObsoleteRedLetterInvoiceApplictationBoePage(self):

        try:

            logger.info(" ----- 单据提交流程开始 ----- ")

            with allure.step("点击选择收入收款页面"):
                self.newObsoleteRedLetterInvoiceApplictationBoePage.selectTabType(
                    '收入收款')
            with allure.step("进入作废/红字发票申请单(新)单据提交页面"):
                self.newObsoleteRedLetterInvoiceApplictationBoePage.boeRntry(
                    '作废/红字发票申请单(新)')

            global boeNum
            boeNum = self.newObsoleteRedLetterInvoiceApplictationBoePage.getBoeNum(
            )

            with allure.step("选择业务类型"):
                self.newObsoleteRedLetterInvoiceApplictationBoePage.input_operationType(
                    'UI红字发票')
            with allure.step("输入备注"):
                self.newObsoleteRedLetterInvoiceApplictationBoePage.input_boeAbstract(
                    '测试作废/红字发票申请单(新)')

            boeNumPath = os.path.join(
                os.path.dirname(os.path.realpath(__file__)), 'invoiceNum.json')
            self.invoiceNum = readInvoiceNum(boeNumPath)

            with allure.step("选择关联发票"):
                self.newObsoleteRedLetterInvoiceApplictationBoePage.relateTargetInvoice(
                    self.invoiceNum)

            with allure.step("点击单据提交"):
                self.newObsoleteRedLetterInvoiceApplictationBoePage.click_boeSubmitButton(
                )
            with allure.step("点击单据关闭按钮"):
                self.newObsoleteRedLetterInvoiceApplictationBoePage.click_close(
                )

            with allure.step("进行单据生成校验"):
                self.newObsoleteRedLetterInvoiceApplictationBoePage.click_more(
                )
                self.newObsoleteRedLetterInvoiceApplictationBoePage.input_boeNumQuery(
                    boeNum)
                self.newObsoleteRedLetterInvoiceApplictationBoePage.click_queryButton(
                )

            with allure.step("断言结果:{}".format(
                    self.newObsoleteRedLetterInvoiceApplictationBoePage.
                    checkBoeNumExistIsOrNot(boeNum))):
                assert self.newObsoleteRedLetterInvoiceApplictationBoePage.checkBoeNumExistIsOrNot(
                    boeNum) == True

            logger.info(" ----- 单据提交流程结束 ----- ")

        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.newObsoleteRedLetterInvoiceApplictationBoePage.screenshot(
                code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.newObsoleteRedLetterInvoiceApplictationBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.newObsoleteRedLetterInvoiceApplictationBoePage.screenshot(
                code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            assert 1 == 1
    def test_newDomesticTravel(self, newDomesticTravelBoe_testdata):
        try:
            logger.info(" ----- 单据流程开始 ----- ")
            with allure.step("打开费用报销单据选择页面"):
                sleep(3)
                self.newDomesticTravelBoePage.open_boeReimburse()
            with allure.step("打开的单据类型为:{} ,选择的单据业务类型为: {}".format(
                    '差旅报账单', newDomesticTravelBoe_testdata['operationType'])):
                try:
                    self.newDomesticTravelBoePage.open_boe(
                        '差旅报账单',
                        newDomesticTravelBoe_testdata['operationType'])
                except:
                    sleep(3)
                    logger.error(" Don't find Boe, Try again")
                    self.newDomesticTravelBoePage.open_boe(
                        '差旅报账单',
                        newDomesticTravelBoe_testdata['operationType'])

            global boeNum
            boeNum = self.newDomesticTravelBoePage.getBoeNum()

            with allure.step("输入业务类型"):
                self.newDomesticTravelBoePage.input_operationType(
                    newDomesticTravelBoe_testdata['operationType'])
            with allure.step("输入备注"):
                self.newDomesticTravelBoePage.input_boeAbstract(
                    newDomesticTravelBoe_testdata['boeAbstract'])

            with allure.step("增加发票"):
                self.newDomesticTravelBoePage.click_addInvoiceButton()
                self.newDomesticTravelBoePage.click_invoiceType()
                # 差旅火车票新增
                invoiceFactory.get_invoice(
                    self.login.driver, '火车票', 'boeInvoicePage').getTickets(
                        # datetime.datetime.now().strftime("%Y-%m-%d")
                        '2021-02-21',
                        newDomesticTravelBoe_testdata['trainInvoice']
                        ['invoicePersonType'],
                        newDomesticTravelBoe_testdata['trainInvoice']
                        ['invoicePersonName'],
                        newDomesticTravelBoe_testdata['trainInvoice']
                        ['invoiceFromCity'],
                        newDomesticTravelBoe_testdata['trainInvoice']
                        ['invoiceToCity'],
                        newDomesticTravelBoe_testdata['trainInvoice']
                        ['invoiceSiteType'],
                        newDomesticTravelBoe_testdata['trainInvoice']
                        ['invoiceTicketFee'],
                        newDomesticTravelBoe_testdata['trainInvoice']
                        ['invoiceIsReplace'])

            with allure.step("选择部门"):
                self.newDomesticTravelBoePage.selectDepartment(
                    newDomesticTravelBoe_testdata['deptCode'],
                    newDomesticTravelBoe_testdata['deptName'])
            with allure.step("输入项目"):
                self.newDomesticTravelBoePage.input_projectId(
                    newDomesticTravelBoe_testdata['projectName'])

            with allure.step("点击单据提交"):
                self.newDomesticTravelBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.newDomesticTravelBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.newDomesticTravelBoePage.click_myBoeList()
                self.newDomesticTravelBoePage.click_moreButton()
                self.newDomesticTravelBoePage.input_boeNo(boeNum)
                self.newDomesticTravelBoePage.click_boeNoSelectButton()
                status = self.newDomesticTravelBoePage.selectResultIsOrNot(
                    boeNum)

            logger.info(" ----- 单据提交流程结束 ----- ")
            assert status == True

        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.newDomesticTravelBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.newDomesticTravelBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.newDomesticTravelBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            assert 1 == 1
예제 #28
0
    def test_comFeeApply(self, comFeeApplyBoe_testdata):
        try:
            logger.info(" ----- 单据流程开始 ----- ")
            with allure.step("打开事项申请选择页面"):
                sleep(3)
                self.comFeeApplyBoePage.open_boeApply()
            with allure.step("打开的单据类型为:{} ,选择的单据业务类型为: {}".format(
                    '通用费用申请单', comFeeApplyBoe_testdata['operationType'])):
                try:
                    self.comFeeApplyBoePage.open_boe(
                        '通用费用申请单', comFeeApplyBoe_testdata['operationType'])
                except:
                    sleep(3)
                    logger.error(" Don't find Boe, Try again")
                    self.comFeeApplyBoePage.open_boe(
                        '通用费用申请单', comFeeApplyBoe_testdata['operationType'])

            global boeNum
            boeNum = self.comFeeApplyBoePage.getBoeNum()

            with allure.step("输入业务类型:"):
                self.comFeeApplyBoePage.input_operationType(
                    comFeeApplyBoe_testdata['operationType'])
            with allure.step("输入备注"):
                self.comFeeApplyBoePage.input_boeAbstract(
                    comFeeApplyBoe_testdata['boeAbstract'])

            with allure.step("选择申请类型"):
                self.comFeeApplyBoePage.input_operationSubTypeId(
                    comFeeApplyBoe_testdata['operationSubTypeId'])
            with allure.step("输入申请金额"):
                self.comFeeApplyBoePage.input_expenseAmount(
                    comFeeApplyBoe_testdata['expenseAmount'])
            with allure.step("输入申请说明"):
                self.comFeeApplyBoePage.input_remark(
                    comFeeApplyBoe_testdata['remark'])

            with allure.step("点击单据提交"):
                self.comFeeApplyBoePage.click_boeSubmitButton()
            with allure.step("点击单据关闭按钮"):
                self.comFeeApplyBoePage.click_close()

            with allure.step("进行单据生成校验"):
                self.comFeeApplyBoePage.click_myBoeList()
                self.comFeeApplyBoePage.click_moreButton()
                self.comFeeApplyBoePage.input_boeNo(boeNum)
                self.comFeeApplyBoePage.click_boeNoSelectButton()
                status = self.comFeeApplyBoePage.selectResultIsOrNot(boeNum)

            logger.info(" ----- 单据提交流程结束 ----- ")
            assert status == True

        except Exception as e:
            logger.error("出现异常,异常信息为:{}".format(type(e)))
            code = 'wrong'
            timeNow = getNowTime()
            self.comFeeApplyBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            self.comFeeApplyBoePage.driver.quit()
            assert 1 == 0

        else:
            logger.info("测试用例执行成功")
            code = 'success'
            timeNow = getNowTime()
            self.comFeeApplyBoePage.screenshot(code, timeNow)
            allure.attach.file(getPicturePath(code, timeNow),
                               name=timeNow + code + "screenshot",
                               attachment_type=allure.attachment_type.PNG)
            assert 1 == 1