Esempio n. 1
0
class weibo:
    def __init__(self, **kwargs):
        self.__logger = ILog(__file__)
        self.path = set_img_res_path(__file__)
        self.robot_no = ''
        self.proc_no = ''
        self.job_no = ''
        self.input_arg = ''
        if ('robot_no' in kwargs.keys()):
            self.robot_no = kwargs['robot_no']
        if ('proc_no' in kwargs.keys()):
            self.proc_no = kwargs['proc_no']
        if ('job_no' in kwargs.keys()):
            self.job_no = kwargs['job_no']
        ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout
        sys.stdout = StdOutHook(self.job_no, sys.stdout)
        ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr
        sys.excepthook = ExceptionHandler.handle_exception
        if ('input_arg' in kwargs.keys()):
            self.input_arg = kwargs['input_arg']
            if (len(self.input_arg) <= 0):
                self.input_arg = iinput.load_init(__file__)
            if self.input_arg is None:
                sys.exit(0)

    def flow1(self):
        #鼠标点击
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow1,StepNodeTag:2020112121391871676,Title:鼠标点击,Note:'
        )
        selectorJson = {
            "selector": [{
                "ControlType": "文本",
                "ControlTypeID": "0xC364",
                "Index": "1"
            }, {
                "ControlType": "窗格",
                "ControlTypeID": "0xC371",
                "Index": "1"
            }, {
                "ControlType": "窗格",
                "ControlTypeID": "0xC371",
                "Index": "1"
            }, {
                "ControlType": "列表项目",
                "ControlTypeID": "0xC357",
                "Index": "8"
            }, {
                "ControlType": "列表",
                "ControlTypeID": "0xC358",
                "Index": "1"
            }, {
                "ControlType": "窗格",
                "ControlTypeID": "0xC371",
                "Index": "1"
            }, {
                "ControlType": "窗格",
                "ControlTypeID": "0xC371",
                "Index": "2"
            }, {
                "ControlType": "窗格",
                "ControlTypeID": "0xC371",
                "Index": "2"
            }, {
                "ControlType": "窗格",
                "ControlTypeID": "0xC371",
                "Index": "2"
            }, {
                "ControlType": "窗格",
                "ControlTypeID": "0xC371",
                "Index": "2"
            }]
        }
        iautomation.do_click(waitfor=10.000,
                             run_mode='unctrl',
                             button='left',
                             curson='center',
                             win_name=r'微信',
                             win_class=r'WeChatMainWndForPC',
                             selector=selectorJson)

    def Main(self):
        lv_1 = 'body > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(2) > DIV:nth-of-type(1) > DIV:nth-of-type(2) > DIV:nth-of-type(2) > DIV:nth-of-type(7) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(3) > UL:nth-of-type(1) > LI:nth-of-type('
        lv_2 = ') > DIV:nth-of-type(1) > DIV:nth-of-type(2) > DIV:nth-of-type(5) > P:nth-of-type(1) > A:nth-of-type(1) > SPAN:nth-of-type(1)'
        lv_3 = None
        lv_4 = None
        flag = None
Esempio n. 2
0
class NewProject1:
     
    def __init__(self,**kwargs):
        self.__logger = ILog(__file__)
        self.path = set_img_res_path(__file__)
        self.robot_no = ''
        self.proc_no = ''
        self.job_no = ''
        self.input_arg = ''
        if('robot_no' in kwargs.keys()):
            self.robot_no = kwargs['robot_no']
        if('proc_no' in kwargs.keys()):
            self.proc_no = kwargs['proc_no']
        if('job_no' in kwargs.keys()):
            self.job_no = kwargs['job_no']
        ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout
        sys.stdout = StdOutHook(self.job_no, sys.stdout)
        ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr
        sys.excepthook = ExceptionHandler.handle_exception
        if('input_arg' in kwargs.keys()):
            self.input_arg = kwargs['input_arg']
            if(len(self.input_arg) <= 0):
                self.input_arg = iinput.load_init(__file__)
            if self.input_arg is None:
                sys.exit(0)
      
    def flow1(self):
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:2020102811431669279,Title:鼠标点击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',offsetX=100,times=2,image=r'snapshot_20201029102745076.png',image_size=r'107X19',win_title=r'银行日记账-条件查询',continue_on_error='break',img_res_path = self.path)
        #模拟按键
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:2020102811443953682,Title:模拟按键,Note:')
        time.sleep(0.3)
        ikeyboard.key_send_cs(waitfor=10.000,text='2016')
        time.sleep(0.3)
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029104525554947,Title:鼠标点击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',offsetX=240,times=2,image=r'snapshot_20201029102745076.png',image_size=r'107X19',win_title=r'银行日记账-条件查询',continue_on_error='break',img_res_path = self.path)
        #模拟按键
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029104628537954,Title:模拟按键,Note:')
        ikeyboard.key_send_cs(waitfor=10.000,text=11)
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029103034188926,Title:鼠标点击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',offsetX=100,times=2,image=r'snapshot_20201029103053436.png',image_size=r'94X18',win_title=r'银行日记账-条件查询',continue_on_error='break',img_res_path = self.path)
        time.sleep(0.3)
        #模拟按键
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029102936035924,Title:模拟按键,Note:')
        time.sleep(0.3)
        ikeyboard.key_send_cs(waitfor=10.000,text='2017')
        time.sleep(0.3)
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029104712257957,Title:鼠标点击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',offsetX=240,times=2,image=r'snapshot_20201029103053436.png',image_size=r'94X18',win_title=r'银行日记账-条件查询',continue_on_error='break',img_res_path = self.path)
        time.sleep(0.3)
        #模拟按键
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029104741631965,Title:模拟按键,Note:')
        ikeyboard.key_send_cs(waitfor=10.000,text='11')
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:2020102811454933884,Title:鼠标点击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201028114606050.png',image_size=r'79X24',win_title=r'银行日记账-条件查询',continue_on_error='break',img_res_path = self.path)
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201028133001493128,Title:鼠标点击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201028133026462.png',image_size=r'73X91',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path)
        #模拟按键
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201028133117833130,Title:模拟按键,Note:')
        ikeyboard.key_send_cs(waitfor=10.000,text='1102{Enter}{Enter}')
        #图片检测
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029092629318884,Title:图片检测,Note:')
        tvar_20201029092629318885=iimg.img_exists(waitfor=30.000,win_title=r'金蝶EAS-IT_Test',image=r'snapshot_20201029092535882.png',img_res_path = self.path)
        print('[flow1] [图片检测] [20201029092629318884]  返回值:[' + str(type(tvar_20201029092629318885)) + ']' + str(tvar_20201029092629318885))
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:2020102813020652490,Title:鼠标点击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201029091730871.png',image_size=r'79X23',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path)
      
    def flow2(self,fangshi=None,leixing=None,initial=4,num=0,excel=0):
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201029100501969918,Title:鼠标点击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',offsetX=10,image=r'snapshot_20201029100607886.png',image_size=r'14X24',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path)
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201029100714286921,Title:鼠标点击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201029100801595.png',image_size=r'85X22',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path)
        #工作表行数获取
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028230910820504,Title:工作表行数获取,Note:')
        excel=iexcel.get_rows_count(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx')
        print('[flow2] [工作表行数获取] [20201028230910820504]  返回值:[' + str(type(excel)) + ']' + str(excel))
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028143452321202,Title:鼠标点击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201028143508572.png',image_size=r'77X29',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path)
        #模拟按键
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201029015023339827,Title:模拟按键,Note:')
        ikeyboard.key_send_cs(waitfor=10.000,text='{Tab}')
        # For循环
        self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:20201028230954859509,Title:For循环,Note:')
        for num in range(excel-3):
            #单元格读取
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201029012445614787,Title:单元格读取,Note:')
            time.sleep(0.3)
            tvar_20201029012445614788=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='B'+str(initial),cell_type='time')
            print('[flow2] [单元格读取] [20201029012445614787]  返回值:[' + str(type(tvar_20201029012445614788)) + ']' + str(tvar_20201029012445614788))
            time.sleep(0.3)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028143734693212,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201029012445614788)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028150809975282,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text='{Tab}')
            #单元格读取
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028144321938225,Title:单元格读取,Note:')
            time.sleep(0.3)
            tvar_20201028144321939226=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='C'+str(initial),cell_type='time')
            print('[flow2] [单元格读取] [20201028144321938225]  返回值:[' + str(type(tvar_20201028144321939226)) + ']' + str(tvar_20201028144321939226))
            time.sleep(0.3)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028144335510228,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201028144321939226)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028144459937234,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text='{Tab}')
            #单元格读取
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028144459937236,Title:单元格读取,Note:')
            time.sleep(0.3)
            tvar_20201028144459937237=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='I'+str(initial),cell_type='string')
            print('[flow2] [单元格读取] [20201028144459937236]  返回值:[' + str(type(tvar_20201028144459937237)) + ']' + str(tvar_20201028144459937237))
            time.sleep(0.3)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028144459937235,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201028144459937237)
            time.sleep(0.5)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028151111503295,Title:模拟按键,Note:')
            time.sleep(0.5)
            ikeyboard.key_send_cs(waitfor=10.000,text='{Tab}')
            #单元格读取
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291412063991055,Title:单元格读取,Note:')
            time.sleep(0.3)
            leixing=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='D'+str(initial),cell_type='string')
            print('[flow2] [单元格读取] [202010291412063991055]  返回值:[' + str(type(leixing)) + ']' + str(leixing))
            time.sleep(0.3)
            # IF分支
            self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:202010291416021701074,Title:IF分支,Note:')
            if leixing == '银收':
                #模拟按键
                self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291416444871078,Title:模拟按键,Note:')
                ikeyboard.key_send_cs(waitfor=10.000,text='{Down 15}')
            elif leixing == '银付':
                #模拟按键
                self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291417369811080,Title:模拟按键,Note:')
                ikeyboard.key_send_cs(waitfor=10.000,text='{Down 8}')
            else:
                pass
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028153949690307,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text='{Enter}')
            #单元格读取
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154040326309,Title:单元格读取,Note:')
            time.sleep(0.3)
            tvar_20201028154040327310=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='E'+str(initial),cell_type=None)
            print('[flow2] [单元格读取] [20201028154040326309]  返回值:[' + str(type(tvar_20201028154040327310)) + ']' + str(tvar_20201028154040327310))
            time.sleep(0.3)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154124182312,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201028154040327310)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028173223637496,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text='{Tab 4}')
            #单元格读取
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291422234261086,Title:单元格读取,Note:')
            time.sleep(0.3)
            fangshi=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='J'+str(initial),cell_type='string')
            print('[flow2] [单元格读取] [202010291422234261086]  返回值:[' + str(type(fangshi)) + ']' + str(fangshi))
            time.sleep(0.3)
            # IF分支
            self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:202010291423319511100,Title:IF分支,Note:')
            if fangshi =='电汇':
                #模拟按键
                self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291426471281103,Title:模拟按键,Note:')
                ikeyboard.key_send_cs(waitfor=10.000,text='{Down 8}')
            elif fangshi =='银行承兑汇票(收)':
                #模拟按键
                self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291427017501104,Title:模拟按键,Note:')
                ikeyboard.key_send_cs(waitfor=10.000,text='{Down 3}')
            elif fangshi =='转帐':
                #模拟按键
                self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291427022791107,Title:模拟按键,Note:')
                ikeyboard.key_send_cs(waitfor=10.000,text='{Down 17}')
            else:
                pass
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154301537329,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text='{Enter}')
            #单元格读取
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154445770331,Title:单元格读取,Note:')
            time.sleep(0.3)
            tvar_20201028154445771332=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='K'+str(initial),cell_type='string')
            print('[flow2] [单元格读取] [20201028154445770331]  返回值:[' + str(type(tvar_20201028154445771332)) + ']' + str(tvar_20201028154445771332))
            time.sleep(0.3)
            #replace
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028165150667415,Title:replace,Note:')
            tvar_20201028165150667416=rpa_str.replace(string=tvar_20201028154445771332,old='#',new='{#}')
            print('[flow2] [replace] [20201028165150667415]  返回值:[' + str(type(tvar_20201028165150667416)) + ']' + str(tvar_20201028165150667416))
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028165226010429,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201028165150667416)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154630210337,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text='{Tab}')
            #单元格读取
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154707544339,Title:单元格读取,Note:')
            time.sleep(0.3)
            tvar_20201028154707545340=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='L'+str(initial),cell_type=None)
            print('[flow2] [单元格读取] [20201028154707544339]  返回值:[' + str(type(tvar_20201028154707545340)) + ']' + str(tvar_20201028154707545340))
            time.sleep(0.3)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154718140342,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201028154707545340)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154748193347,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text='{Tab}')
            #单元格读取
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154805912349,Title:单元格读取,Note:')
            time.sleep(0.3)
            tvar_20201028154805912350=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='M'+str(initial),cell_type=None)
            print('[flow2] [单元格读取] [20201028154805912349]  返回值:[' + str(type(tvar_20201028154805912350)) + ']' + str(tvar_20201028154805912350))
            time.sleep(0.3)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154840804352,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201028154805912350)
            #模拟按键
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028172525264494,Title:模拟按键,Note:')
            ikeyboard.key_send_cs(waitfor=10.000,text='{Tab 4}')
            #相加
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201029015908212843,Title:相加,Note:')
            initial=rpa_fun.add(a=initial,b=1)
            print('[flow2] [相加] [20201029015908212843]  返回值:[' + str(type(initial)) + ']' + str(initial))
        #模拟按键
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201029100341149915,Title:模拟按键,Note:')
        ikeyboard.key_send_cs(waitfor=10.000)
      
    def leixing(self):
        pass
      
    def login(self):
        #热键输入
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login,StepNodeTag:2020102716440633945,Title:热键输入,Note:')
        ikeyboard.key_send_cs(waitfor=10.000,text=r'#d')
        #鼠标双击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login,StepNodeTag:2020102716440633944,Title:鼠标双击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',times=2,image=r'snapshot_20201029103253721.png',image_size=r'38X29',img_res_path = self.path)
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login,StepNodeTag:2020102716440633942,Title:鼠标点击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201027163736752.png',image_size=r'272X15',win_title=r'金蝶EAS系统登录',continue_on_error='break',img_res_path = self.path)
        #模拟按键
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login,StepNodeTag:2020102716440633941,Title:模拟按键,Note:')
        ikeyboard.key_send_cs(waitfor=10.000,text="123456")
        #鼠标点击
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login,StepNodeTag:2020102716440633943,Title:鼠标点击,Note:')
        iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201027164204785.png',image_size=r'76X18',win_title=r'金蝶EAS系统登录',continue_on_error='break',img_res_path = self.path)
      
    def Main(self):
        #子流程
        self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102716441979756,Title:子流程,Note:')
        tvar20201027164419797561=self.login()
        print('[Main] [子流程] [2020102716441979756]  返回值:[' + str(type(tvar20201027164419797561)) + ']' + str(tvar20201027164419797561))
        # Try异常
        self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:Main,StepNodeTag:2020102813042663292,Title:Try异常,Note:')
        try:
            #图片检测
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102813045662794,Title:图片检测,Note:')
            tvar_2020102813045662895=iimg.img_exists(waitfor=30.000,win_title=r'账号重复登录',image=r'snapshot_20201028130520424.png',img_res_path = self.path)
            print('[Main] [图片检测] [2020102813045662794]  返回值:[' + str(type(tvar_2020102813045662895)) + ']' + str(tvar_2020102813045662895))
            #鼠标点击
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102813052718697,Title:鼠标点击,Note:')
            iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201028130553617.png',image_size=r'80X21',win_title=r'账号重复登录',continue_on_error='break',img_res_path = self.path)
        except Exception as e:
            pass
        finally:
            #鼠标点击
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102716442586158,Title:鼠标点击,Note:')
            time.sleep(5)
            iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201029105623930.png',image_size=r'82X13',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path)
            #鼠标点击
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102716463348960,Title:鼠标点击,Note:')
            iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201027164652739.png',image_size=r'151X20',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path)
            #鼠标点击
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102716465797562,Title:鼠标点击,Note:')
            iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201027164724771.png',image_size=r'223X28',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path)
            #鼠标双击
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102716515656866,Title:鼠标双击,Note:')
            iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',times=2,image=r'snapshot_20201027165408189.png',image_size=r'212X21',win_title=r'金蝶EAS-IT_Test',img_res_path = self.path)
            #子流程
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102811290944859,Title:子流程,Note:')
            tvar20201028112909448591=self.flow1()
            print('[Main] [子流程] [2020102811290944859]  返回值:[' + str(type(tvar20201028112909448591)) + ']' + str(tvar20201028112909448591))
            #图片检测
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:20201029092656397894,Title:图片检测,Note:')
            tvar_20201029092656397895=iimg.img_exists(waitfor=30.000,win_title=r'金蝶EAS-IT_Test',image=r'snapshot_20201029092735462.png',img_res_path = self.path)
            print('[Main] [图片检测] [20201029092656397894]  返回值:[' + str(type(tvar_20201029092656397895)) + ']' + str(tvar_20201029092656397895))
            #子流程
            self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:20201028173523203502,Title:子流程,Note:')
            tvar202010281735232035021=self.flow2()
            print('[Main] [子流程] [20201028173523203502]  返回值:[' + str(type(tvar202010281735232035021)) + ']' + str(tvar202010281735232035021))
Esempio n. 3
0
class RPA_D3:
    def __init__(self, **kwargs):
        self.__logger = ILog(__file__)
        self.path = set_img_res_path(__file__)
        self.robot_no = ''
        self.proc_no = ''
        self.job_no = ''
        self.input_arg = ''
        if ('robot_no' in kwargs.keys()):
            self.robot_no = kwargs['robot_no']
        if ('proc_no' in kwargs.keys()):
            self.proc_no = kwargs['proc_no']
        if ('job_no' in kwargs.keys()):
            self.job_no = kwargs['job_no']
        ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout
        sys.stdout = StdOutHook(self.job_no, sys.stdout)
        ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr
        sys.excepthook = ExceptionHandler.handle_exception
        if ('input_arg' in kwargs.keys()):
            self.input_arg = kwargs['input_arg']
            if (len(self.input_arg) <= 0):
                self.input_arg = iinput.load_init(__file__)
            if self.input_arg is None:
                sys.exit(0)

    def Dataframe_list(self):
        value_isearch03 = None
        #读取Excel
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Dataframe_list,StepNodeTag:2020091715025272589,Title:读取Excel,Note:'
        )
        tvar_2020091715025272690 = pd.read_excel(
            io='D:/YiSaiQi/RPA_D3/mydata.xls')
        #表格过滤
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Dataframe_list,StepNodeTag:2020091714592597678,Title:表格过滤,Note:'
        )
        value_isearch03 = tvar_2020091715025272690[(
            tvar_2020091715025272690['产品代码'].str.startswith('i-Search-03'))]
        #设置变量
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Dataframe_list,StepNodeTag:20200917150802293115,Title:设置变量,Note:'
        )
        value_isearch03 = value_isearch03.values.tolist()
        # For循环
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Dataframe_list,StepNodeTag:20200917151128158119,Title:For循环,Note:'
        )
        for tvar_20200917151128161120 in value_isearch03:
            #输出
            self.__logger.dlogs(
                job_no=self.job_no,
                logmsg=
                'Flow:Dataframe_list,StepNodeTag:2020091715004175083,Title:输出,Note:'
            )
            rpa_str.iprints(tvar_20200917151128161120)

    def Excel(self):
        sheet2_val = None
        sheet1_val = None
        #读取Excel
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Excel,StepNodeTag:20200917160132552143,Title:读取Excel,Note:')
        sheet1_val = pd.read_excel(io='D:/YiSaiQi/RPA_D3/mydata.xls')
        #读取Excel
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Excel,StepNodeTag:20200917160727776167,Title:读取Excel,Note:')
        sheet2_val = pd.read_excel(io='D:/YiSaiQi/RPA_D3/mydata.xls',
                                   sheet_name=1)
        #代码块
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:Excel,StepNodeTag:20200917161108141183,Title:代码块,Note:'
        )
        sheet1_val = sheet1_val.append(sheet2_val)
        #输出
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:Excel,StepNodeTag:20200917161214523186,Title:输出,Note:'
        )
        rpa_str.iprints(sheet1_val)
        # Try异常
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Excel,StepNodeTag:20200917162950407191,Title:Try异常,Note:')
        try:
            #创建excel
            self.__logger.dlogs(
                job_no=self.job_no,
                logmsg=
                'Flow:Excel,StepNodeTag:20200917154223848138,Title:创建excel,Note:'
            )
            iexcel.create_excel(path='D:/YiSaiQi/RPA_D3',
                                file_name='Create_excel.xls')
        except Exception as e:
            #导出excel
            self.__logger.dlogs(
                job_no=self.job_no,
                logmsg=
                'Flow:Excel,StepNodeTag:20200917163240519199,Title:导出excel,Note:'
            )
            icsv.write_excel(path='D:/YiSaiQi/RPA_D3/Create_excel.xls',
                             df=sheet1_val)
        finally:
            #导出excel
            self.__logger.dlogs(
                job_no=self.job_no,
                logmsg=
                'Flow:Excel,StepNodeTag:20200917160944573180,Title:导出excel,Note:'
            )
            icsv.write_excel(path='D:/YiSaiQi/RPA_D3/Create_excel.xls',
                             df=sheet1_val)

    def flow1(self):
        #单元格读取
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow1,StepNodeTag:202009171430210059,Title:单元格读取,Note:'
        )
        tvar_2020091714302100810 = iexcel.read_cell(
            path='D:/YiSaiQi/RPA_D3/D3_demo.xls', cell_type=None)
        # Return返回
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:flow1,StepNodeTag:2020091714434624064,Title:Return返回,Note:')
        return tvar_2020091714302100810

    def flow2(self, excel=None):
        #消息框
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow2,StepNodeTag:2020091714340135526,Title:消息框,Note:'
        )
        ibox.msgs_box('成功' + excel, timeout=0)

    def Main(self):
        #子流程
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:Main,StepNodeTag:2020091714405559957,Title:子流程,Note:')
        tvar20200917144055599571 = self.flow1()
        #子流程
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:Main,StepNodeTag:2020091714441293867,Title:子流程,Note:')
        tvar20200917144412938671 = self.flow2(excel=tvar20200917144055599571)
Esempio n. 4
0
class DEMO2:
    def __init__(self, **kwargs):
        self.__logger = ILog(__file__)
        self.path = set_img_res_path(__file__)
        self.robot_no = ''
        self.proc_no = ''
        self.job_no = ''
        self.input_arg = ''
        if ('robot_no' in kwargs.keys()):
            self.robot_no = kwargs['robot_no']
        if ('proc_no' in kwargs.keys()):
            self.proc_no = kwargs['proc_no']
        if ('job_no' in kwargs.keys()):
            self.job_no = kwargs['job_no']
        ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout
        sys.stdout = StdOutHook(self.job_no, sys.stdout)
        ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr
        sys.excepthook = ExceptionHandler.handle_exception
        if ('input_arg' in kwargs.keys()):
            self.input_arg = kwargs['input_arg']
            if (len(self.input_arg) <= 0):
                self.input_arg = iinput.load_init(__file__)
            if self.input_arg is None:
                sys.exit(0)

    def Excel_write(self):
        value1 = None
        #获取文本
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Excel_write,StepNodeTag:202009180744505107,Title:获取文本,Note:')
        value1 = iie.get_text(
            waitfor=10.000,
            selector=
            r'#page > NAV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(3) > UL:nth-of-type(1) > LI:nth-of-type(8) > A:nth-of-type(1)',
            url=r'https://www.i-search.com.cn/course.html')
        print('[Excel_write] [获取文本] [202009180744505107]  返回值:[' +
              str(type(value1)) + ']' + str(value1))
        #单元格写入
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Excel_write,StepNodeTag:2020091807473501913,Title:单元格写入,Note:'
        )
        tvar_2020091807473502914 = iexcel.write_cell(
            path='D:/YiSaiQi/DEMO2/Day2.xls', text=value1)
        print('[Excel_write] [单元格写入] [2020091807473501913]  返回值:[' +
              str(type(tvar_2020091807473502914)) + ']' +
              str(tvar_2020091807473502914))

    def OCR(self):
        YZM = None
        #截图
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:OCR,StepNodeTag:20200918084212118111,Title:截图,Note:')
        tvar_20200918084212118112 = iimg.capture_image(
            waitfor=30.000,
            win_title=r'中国工商银行企业网上银行 - Internet Explorer',
            left_indent=935,
            top_indent=458,
            width=90,
            height=34)
        print('[OCR] [截图] [20200918084212118111]  返回值:[' +
              str(type(tvar_20200918084212118112)) + ']' +
              str(tvar_20200918084212118112))
        #获取OCR文本
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:OCR,StepNodeTag:2020091808312854183,Title:获取OCR文本,Note:')
        YZM = iocr.general_recognize(
            image_path=tvar_20200918084212118112,
            apiKey='c578a472e212448fb9f78b17a79fffc9',
            secretKey='5588921ccc2047fd87a2e54fabee90ed')
        print('[OCR] [获取OCR文本] [2020091808312854183]  返回值:[' + str(type(YZM)) +
              ']' + str(YZM))
        #replace
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:OCR,StepNodeTag:2020091808351721592,Title:replace,Note:')
        tvar_2020091808351722593 = rpa_str.replace(string=YZM, old=' ', new='')
        print('[OCR] [replace] [2020091808351721592]  返回值:[' +
              str(type(tvar_2020091808351722593)) + ']' +
              str(tvar_2020091808351722593))
        #输出
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:OCR,StepNodeTag:20200918083727282102,Title:输出,Note:')
        rpa_str.iprints(tvar_2020091808351722593)

    def for_demo(self):
        # For循环
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:for_demo,StepNodeTag:2020091808042353439,Title:For循环,Note:')
        for i in [1, 2, 3, 4, 5]:
            #输出
            self.__logger.dlogs(
                job_no=self.job_no,
                logmsg=
                'Flow:for_demo,StepNodeTag:2020091808050105143,Title:输出,Note:')
            rpa_str.iprints(i)

    def pic_JC(self):
        #元素截图
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:pic_JC,StepNodeTag:2020091808241867472,Title:元素截图,Note:')
        tvar_2020091808243847274 = iie.capture_element_img(
            waitfor=10.000,
            win_title=r'金融RPA_银行RPA机器人_RPA金融银行解决方案_艺赛旗 - Internet Explorer',
            selector=
            r'#fh5co-header > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(2) > IMG:nth-of-type(1)',
            in_img_path=r'C:/Users/帅气可爱的小飞/Desktop/图片素材',
            url=r'https://www.i-search.com.cn/finance.html')
        print('[pic_JC] [元素截图] [2020091808241867472]  返回值:[' +
              str(type(tvar_2020091808243847274)) + ']' +
              str(tvar_2020091808243847274))
        #输出
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:pic_JC,StepNodeTag:2020091808252203975,Title:输出,Note:'
        )
        rpa_str.iprints(tvar_2020091808243847274)

    def while_dmeo(self):
        carr = 0
        # While循环
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:while_dmeo,StepNodeTag:2020091807503206120,Title:While循环,Note:'
        )
        while carr <= 100:
            #相加
            self.__logger.dlogs(
                job_no=self.job_no,
                logmsg=
                'Flow:while_dmeo,StepNodeTag:2020091807551612223,Title:相加,Note:'
            )
            carr = rpa_fun.add(a=carr, b=1)
            print('[while_dmeo] [相加] [2020091807551612223]  返回值:[' +
                  str(type(carr)) + ']' + str(carr))
            # IF分支
            self.__logger.dlogs(
                job_no=self.job_no,
                logmsg=
                'Flow:while_dmeo,StepNodeTag:2020091807565996529,Title:IF分支,Note:'
            )
            if carr % 2 == 0:
                #输出
                self.__logger.dlogs(
                    job_no=self.job_no,
                    logmsg=
                    'Flow:while_dmeo,StepNodeTag:2020091807574119732,Title:输出,Note:'
                )
                rpa_str.iprints(carr)
            else:
                # Continue继续
                self.__logger.dlogs(
                    job_no=self.job_no,
                    logmsg=
                    'Flow:while_dmeo,StepNodeTag:2020091807582317635,Title:Continue继续,Note:'
                )
                continue

    def Main(self):
        pass
Esempio n. 5
0
class demo1:
    def __init__(self, **kwargs):
        self.__logger = ILog(__file__)
        self.path = set_img_res_path(__file__)
        self.robot_no = ''
        self.proc_no = ''
        self.job_no = ''
        self.input_arg = ''
        if ('robot_no' in kwargs.keys()):
            self.robot_no = kwargs['robot_no']
        if ('proc_no' in kwargs.keys()):
            self.proc_no = kwargs['proc_no']
        if ('job_no' in kwargs.keys()):
            self.job_no = kwargs['job_no']
        ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout
        sys.stdout = StdOutHook(self.job_no, sys.stdout)
        ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr
        sys.excepthook = ExceptionHandler.handle_exception
        if ('input_arg' in kwargs.keys()):
            self.input_arg = kwargs['input_arg']
            if (len(self.input_arg) <= 0):
                self.input_arg = iinput.load_init(__file__)
            if self.input_arg is None:
                sys.exit(0)

    def Baidu_news(self):
        '''打开百度新闻\n'''
        lv_2 = 20
        lv_1 = 10
        #网站
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Baidu_news,StepNodeTag:2020091515062370615,Title:网站,Note:')
        iie.open_url(
            ie_path='C:/Program Files (x86)/Internet Explorer/iexplore.exe',
            url='www.baidu.com')
        #鼠标点击
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Baidu_news,StepNodeTag:2020091515075726216,Title:鼠标点击,Note:点击新闻'
        )
        time.sleep(1)
        iie.do_click_pos(waitfor=10.000,
                         run_mode='unctrl',
                         button='left',
                         curson='center',
                         continue_on_error='break',
                         win_title=r'百度一下,你就知道 - Internet Explorer',
                         selector=r'#s-top-left > A:nth-of-type(1)',
                         url=r'https://www.baidu.com/')
        time.sleep(1)

    def Baidu_search(self, pv_1=None):
        input = 'RPA'
        #网站
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Baidu_search,StepNodeTag:2020091702300252617,Title:网站,Note:')
        iie.open_url(
            ie_path='C:/Program Files (x86)/Internet Explorer/iexplore.exe',
            url='www.baidu.com')
        #鼠标点击
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Baidu_search,StepNodeTag:2020091702303042024,Title:鼠标点击,Note:'
        )
        iie.do_click_pos(waitfor=10.000,
                         run_mode='unctrl',
                         button='left',
                         curson='center',
                         continue_on_error='break',
                         win_title=r'百度一下,你就知道 - Internet Explorer',
                         selector=r'#kw',
                         url=r'https://www.baidu.com/')
        #模拟按键
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Baidu_search,StepNodeTag:2020091702310358326,Title:模拟按键,Note:'
        )
        ikeyboard.key_send_cs(waitfor=10.000, text='{LShift}')
        #模拟按键
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Baidu_search,StepNodeTag:2020091702315568728,Title:模拟按键,Note:'
        )
        ikeyboard.key_send_cs(waitfor=10.000, text=input)
        #鼠标点击
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Baidu_search,StepNodeTag:2020091702332197730,Title:鼠标点击,Note:'
        )
        iie.do_click_pos(waitfor=10.000,
                         run_mode='unctrl',
                         button='left',
                         curson='center',
                         continue_on_error='break',
                         win_title=r'百度一下,你就知道 - Internet Explorer',
                         selector=r'#su',
                         url=r'https://www.baidu.com/')

    def CSM_demo(self):
        product_code = 'i-search-20200917-0351'
        #网站
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:2020091703094021399,Title:网站,Note:')
        iie.open_url(
            ie_path='C:/Program Files (x86)/Internet Explorer/iexplore.exe',
            url='http://122.112.200.222:9080/login.action')
        #设置文本
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917031229648101,Title:设置文本,Note:')
        iie.set_text(
            waitfor=10.000,
            text=r'ceshi001',
            selector=
            r'#loginWrap > UL:nth-of-type(1) > LI:nth-of-type(1) > INPUT:nth-of-type(1)',
            url=r'http://122.112.200.222:9080/login.action')
        #设置文本
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917031301891104,Title:设置文本,Note:')
        iie.set_text(
            waitfor=10.000,
            text=r'typSVU',
            selector=
            r'#loginWrap > UL:nth-of-type(1) > LI:nth-of-type(2) > INPUT:nth-of-type(1)',
            url=r'http://122.112.200.222:9080/login.action')
        #鼠标点击
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917031353836106,Title:鼠标点击,Note:')
        iie.do_click_pos(
            waitfor=10.000,
            run_mode='unctrl',
            button='left',
            curson='center',
            continue_on_error='break',
            win_title=r'双录系统-录音、录像、录屏 - Internet Explorer',
            selector=
            r'#loginWrap > UL:nth-of-type(1) > LI:nth-of-type(2) > INPUT:nth-of-type(2)',
            url=r'http://122.112.200.222:9080/login.action')
        #鼠标点击
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917031452058108,Title:鼠标点击,Note:')
        iie.do_click_pos(waitfor=10.000,
                         run_mode='unctrl',
                         button='left',
                         curson='center',
                         continue_on_error='break',
                         win_title=r'双录系统-录音、录像、录屏 - Internet Explorer',
                         selector=r'#popup_ok',
                         url=r'http://122.112.200.222:9080/login.action')
        #鼠标点击
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917031802702110,Title:鼠标点击,Note:')
        iie.do_click_pos(
            waitfor=10.000,
            run_mode='unctrl',
            button='left',
            curson='center',
            continue_on_error='break',
            win_title=r'双录系统-录音、录像、录屏 - Internet Explorer',
            selector=
            r'#frame-nav > UL:nth-of-type(1) > LI:nth-of-type(1) > A:nth-of-type(1)',
            url=r'http://122.112.200.222:9080/login.action')
        #鼠标点击
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917031836401112,Title:鼠标点击,Note:')
        iie.do_click_pos(
            waitfor=10.000,
            run_mode='unctrl',
            button='left',
            curson='center',
            continue_on_error='break',
            win_title=r'双录系统-录音、录像、录屏 - Internet Explorer',
            selector=
            r'#MenuContext > TABLE:nth-of-type(1) > TBODY:nth-of-type(1) > TR:nth-of-type(1) > TD:nth-of-type(2) > LI:nth-of-type(5) > A:nth-of-type(1)',
            url=r'http://122.112.200.222:9080/login.action')
        #鼠标点击
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917031929670114,Title:鼠标点击,Note:')
        iie.do_click_pos(
            waitfor=10.000,
            run_mode='unctrl',
            button='left',
            curson='center',
            continue_on_error='break',
            win_title=r'双录系统-录音、录像、录屏 - Internet Explorer',
            selector=
            r'#ListForm > DIV:nth-of-type(2) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > A:nth-of-type(2)',
            title=r'理财管理')
        #设置文本
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917032133267116,Title:设置文本,Note:')
        iie.set_text(
            waitfor=10.000,
            text=product_code,
            selector=
            r'body > DIV:nth-of-type(1) > FORM:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(2) > UL:nth-of-type(1) > LI:nth-of-type(1) > INPUT:nth-of-type(1)',
            title=r'理财管理')
        #设置文本
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917032229059118,Title:设置文本,Note:')
        iie.set_text(
            waitfor=10.000,
            text=r'LL-demo',
            selector=
            r'body > DIV:nth-of-type(1) > FORM:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(2) > UL:nth-of-type(1) > LI:nth-of-type(2) > INPUT:nth-of-type(1)',
            title=r'理财管理')
        #设置文本
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917032304015120,Title:设置文本,Note:')
        iie.set_text(waitfor=10.000,
                     text=r'S8',
                     selector=r'#proType',
                     title=r'理财管理')
        #设置文本
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917032344848122,Title:设置文本,Note:')
        iie.set_text(waitfor=10.000,
                     text=r'5',
                     selector=r'#proRiskLevel',
                     title=r'理财管理')
        #设置文本
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917032410932124,Title:设置文本,Note:')
        iie.set_text(waitfor=10.000,
                     text=r'3',
                     selector=r'#videoDtaTime',
                     title=r'理财管理')
        #设置文本
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917032513188130,Title:设置文本,Note:')
        iie.set_text(waitfor=10.000,
                     text=r'刘浪测试',
                     selector=r'#proDesc',
                     title=r'理财管理')
        #鼠标点击
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:CSM_demo,StepNodeTag:20200917032903457132,Title:鼠标点击,Note:')
        iie.do_click_pos(
            waitfor=5.000,
            run_mode='unctrl',
            button='left',
            curson='center',
            continue_on_error='break',
            win_title=r'双录系统-录音、录像、录屏 - Internet Explorer',
            selector=
            r'#DetailForm > DIV:nth-of-type(1) > DIV:nth-of-type(3) > INPUT:nth-of-type(1)',
            title=r'理财管理')

    def Excel(self):
        text = None
        #获取文本
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:Excel,StepNodeTag:2020091703541846134,Title:获取文本,Note:'
        )
        text = iie.get_text(
            waitfor=10.000,
            selector=
            r'#frame-nav > UL:nth-of-type(1) > LI:nth-of-type(1) > A:nth-of-type(1)',
            url=r'http://122.112.200.222:9080/login.action')
        print('[Excel] [获取文本] [2020091703541846134]  返回值:[' + str(type(text)) +
              ']' + str(text))
        #输出
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:Excel,StepNodeTag:2020091703550173641,Title:输出,Note:')
        rpa_str.iprints(text)
        #单元格写入
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:Excel,StepNodeTag:2020091703553501645,Title:单元格写入,Note:')
        tvar_2020091703553501646 = iexcel.write_cell(
            path='C:/Users/帅气可爱的小飞/Desktop/RPA_test1.xls', text=text)
        print('[Excel] [单元格写入] [2020091703553501645]  返回值:[' +
              str(type(tvar_2020091703553501646)) + ']' +
              str(tvar_2020091703553501646))

    def text_input(self):
        password = None
        #网站
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:text_input,StepNodeTag:2020091702470364538,Title:网站,Note:')
        iie.open_url(
            ie_path='C:/Program Files (x86)/Internet Explorer/iexplore.exe',
            url='www.baidu.com')
        #设置文本
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:text_input,StepNodeTag:2020091702471776644,Title:设置文本,Note:')
        iie.set_text(waitfor=10.000,
                     text=r'RPA',
                     selector=r'.s_ipt',
                     url=r'https://www.baidu.com/')
        #鼠标点击
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:text_input,StepNodeTag:2020091703023316894,Title:鼠标点击,Note:')
        iie.do_click_pos(waitfor=10.000,
                         run_mode='unctrl',
                         button='left',
                         curson='center',
                         continue_on_error='break',
                         win_title=r'百度一下,你就知道 - Internet Explorer',
                         selector=r'#su',
                         url=r'https://www.baidu.com/')

    def Main(self):
        pass
Esempio n. 6
0
class lanhe_fapiao_1:
    def __init__(self, **kwargs):
        self.__logger = ILog(__file__)
        self.path = set_img_res_path(__file__)
        self.robot_no = ''
        self.proc_no = ''
        self.job_no = ''
        self.input_arg = ''
        if ('robot_no' in kwargs.keys()):
            self.robot_no = kwargs['robot_no']
        if ('proc_no' in kwargs.keys()):
            self.proc_no = kwargs['proc_no']
        if ('job_no' in kwargs.keys()):
            self.job_no = kwargs['job_no']
        ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout
        sys.stdout = StdOutHook(self.job_no, sys.stdout)
        ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr
        sys.excepthook = ExceptionHandler.handle_exception
        if ('input_arg' in kwargs.keys()):
            self.input_arg = kwargs['input_arg']
            if (len(self.input_arg) <= 0):
                self.input_arg = iinput.load_init(__file__)
            if self.input_arg is None:
                sys.exit(0)
        self.dict_info = {
            'AmountInWords': '佰叁拾圆叁角肆分',
            'NoteDrawer': '谢登梅',
            'SellerAddress':
            '深州市龙华区庆湾街道庆津大道乌庆旺路文汇处民治商务中心1栋115栋、2、3栋、4幢009栋7553323188',
            'CommodityPrice': '[]',
            'CommodityNum': '[]',
            'SellerRegisterNum': '91440300689404127F',
            'SellerBank': '农业银行龙华支行41028900040099987',
            'Remarks': '订单号1047426466044621910支付日期2020-06-07',
            'CommodityTaxRate': '[]',
            'TotalTax': '62.05',
            'CheckCode': '17960524178417916383',
            'InvoiceCode': '044031900111',
            'InvoiceDate': '2020年06月11日',
            'PurchaserRegisterNum': '91440300MA5EGKDJ92',
            'InvoiceTypeOrg': '深圳增值税电子普通发票',
            'Password': '',
            'PurchaserBank': '',
            'AmountInFiguers': '937.34',
            'Checker': '郑晓碧',
            'TotalAmount': '875.29',
            'CommodityAmount': "[{'row':'1','word':'875.29'}]",
            'PurchaserName': '深圳市蓝禾技术有限公司',
            'CommodityType': '[]',
            'InvoiceType': '电子普通发票',
            'PurchaserAddress': '',
            'CommodityTax': "[{'row':'1','word':'62.05'}]",
            'CommodityUnit': '[]',
            'Payee': '刘笑额',
            'SellerName': '深圳康润华商贸有限公司',
            'CommodityName': "[{'row':'1','word':'(详见销货清单'}]",
            'InvoiceNum': '23838102'
        }

    def flow1(self):
        #增值税发票OCR
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:flow1,StepNodeTag:20201030113643160121,Title:增值税发票OCR,Note:')
        tvar_20201030113643161122 = iocr.vat_recognize(
            image_path='E:/fapiao/不干胶发票0608.pdf')
        print('[flow1] [增值税发票OCR] [20201030113643160121]  返回值:[' +
              str(type(tvar_20201030113643161122)) + ']' +
              str(tvar_20201030113643161122))
        #输出
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow1,StepNodeTag:20201030113715259124,Title:输出,Note:'
        )
        rpa_str.iprints(tvar_20201030113643161122)

    def flow2(self):
        yzm_pic = None
        tishi = None
        list_1 = [
            '电子普通发票', '深圳增值税电子普通发票', '91440300MA5EGKDJ92', '2020年06月11日',
            '044031900111', '23838102', '17960524178417916383', '875.29',
            '62.05', '937.34', "[{'row': '1', 'word': '(详见销货清单'}]"
        ]
        dict_info = {
            'AmountInWords': '佰叁拾圆叁角肆分',
            'NoteDrawer': '谢登梅',
            'SellerAddress':
            '深州市龙华区庆湾街道庆津大道乌庆旺路文汇处民治商务中心1栋115栋、2、3栋、4幢009栋7553323188',
            'CommodityPrice': '[]',
            'CommodityNum': '[]',
            'SellerRegisterNum': '91440300689404127F',
            'SellerBank': '农业银行龙华支行41028900040099987',
            'Remarks': '订单号1047426466044621910支付日期2020-06-07',
            'CommodityTaxRate': '[]',
            'TotalTax': '62.05',
            'CheckCode': '17960524178417916383',
            'InvoiceCode': '044031900111',
            'InvoiceDate': '2020年06月11日',
            'PurchaserRegisterNum': '91440300MA5EGKDJ92',
            'InvoiceTypeOrg': '深圳增值税电子普通发票',
            'Password': '',
            'PurchaserBank': '',
            'AmountInFiguers': '937.34',
            'Checker': '郑晓碧',
            'TotalAmount': '875.29',
            'CommodityAmount': "[{'row':'1','word':'875.29'}]",
            'PurchaserName': '深圳市蓝禾技术有限公司',
            'CommodityType': '[]',
            'InvoiceType': '电子普通发票',
            'PurchaserAddress': '',
            'CommodityTax': "[{'row':'1','word':'62.05'}]",
            'CommodityUnit': '[]',
            'Payee': '刘笑额',
            'SellerName': '深圳康润华商贸有限公司',
            'CommodityName': "[{'row':'1','word':'(详见销货清单'}]",
            'InvoiceNum': '23838102'
        }
        code = None
        #网站
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow2,StepNodeTag:2317224431623,Title:网站,Note:')
        time.sleep(0.5)
        iie.open_url(
            ie_path='C:/Program Files (x86)/Internet Explorer/iexplore.exe',
            url='https://inv-veri.chinatax.gov.cn/index.html')
        time.sleep(0.5)
        # Try异常
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg=
            'Flow:flow2,StepNodeTag:20201027172041803566,Title:Try异常,Note:')
        try:
            #鼠标点击
            self.__logger.dlogs(
                job_no=self.job_no,
                logmsg=
                'Flow:flow2,StepNodeTag:20201027172049219568,Title:鼠标点击,Note:')
            iimg.do_click_pos(waitfor=30.000,
                              button='left',
                              curson='Center',
                              image=r'snapshot_20201029175005894.png',
                              image_size=r'64X15',
                              win_title=r'此站点不安全 - Internet Explorer',
                              continue_on_error='break',
                              img_res_path=self.path)
            #鼠标点击
            self.__logger.dlogs(
                job_no=self.job_no,
                logmsg=
                'Flow:flow2,StepNodeTag:20201027172102123570,Title:鼠标点击,Note:')
            iimg.do_click_pos(waitfor=30.000,
                              button='left',
                              curson='Center',
                              image=r'snapshot_20201029175415351.png',
                              image_size=r'161X28',
                              win_title=r'此站点不安全 - Internet Explorer',
                              continue_on_error='break',
                              img_res_path=self.path)
        except Exception as e:
            pass
        finally:
            pass
        #热键输入
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow2,StepNodeTag:240950181343,Title:热键输入,Note:')
        ikeyboard.key_send_cs(waitfor=10.000, text=r'#{UP}')
        time.sleep(2.5)
        #鼠标点击
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow2,StepNodeTag:2317224431622,Title:鼠标点击,Note:')
        iie.do_click_pos(waitfor=10.000,
                         run_mode='unctrl',
                         button='left',
                         curson='center',
                         continue_on_error='break',
                         win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer',
                         selector=r'#fpdm',
                         url=r'https://inv-veri.chinatax.gov.cn/index.html')
        time.sleep(0.8)
        #模拟按键
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow2,StepNodeTag:2317224431621,Title:模拟按键,Note:输入发票代码'
        )
        time.sleep(0.5)
        ikeyboard.key_send_cs(waitfor=10.000, text='044031900111')
        time.sleep(0.6)
        #模拟按键
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow2,StepNodeTag:2317224431620,Title:模拟按键,Note:')
        time.sleep(0.5)
        ikeyboard.key_send_cs(waitfor=10.000, text='{TAB}')
        #模拟按键
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow2,StepNodeTag:2317224431619,Title:模拟按键,Note:输入发票号码'
        )
        time.sleep(0.5)
        ikeyboard.key_send_cs(waitfor=10.000, text='23838102')
        #模拟按键
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow2,StepNodeTag:2317224431618,Title:模拟按键,Note:')
        time.sleep(0.5)
        ikeyboard.key_send_cs(waitfor=10.000, text='{TAB}')
        #模拟按键
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow2,StepNodeTag:2317224431617,Title:模拟按键,Note:开票日期')
        time.sleep(0.5)
        ikeyboard.key_send_cs(waitfor=10.000, text='20200611')
        #模拟按键
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow2,StepNodeTag:2317224431616,Title:模拟按键,Note:')
        time.sleep(0.5)
        ikeyboard.key_send_cs(waitfor=10.000, text='{Tab}')
        #图片检测
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:flow2,StepNodeTag:2317224431613,Title:图片检测,Note:判断输入内容'
        )
        tvar_2020102717112596416 = iimg.img_exists(
            waitfor=30.000,
            win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer',
            image=r'snapshot_20201030101359793.png',
            img_res_path=self.path)
        print('[flow2] [图片检测] [2317224431613]  返回值:[' +
              str(type(tvar_2020102717112596416)) + ']' +
              str(tvar_2020102717112596416))
        time.sleep(0.5)

    def Main(self):
        #子流程
        self.__logger.dlogs(
            job_no=self.job_no,
            logmsg='Flow:Main,StepNodeTag:20201027172332623803,Title:子流程,Note:'
        )
        tvar202010271723326238031 = self.flow2()
        print('[Main] [子流程] [20201027172332623803]  返回值:[' +
              str(type(tvar202010271723326238031)) + ']' +
              str(tvar202010271723326238031))