def is_check_messageTemplate(self): u'''确认是否存在短信模版''' try: template_message=csv_search.csv_test(filename=Push_Template_path().push_template,indexs=2) time.sleep(0.5) database=MySQL() template_code = template_message[5] template_name=template_message[1] sql="Select * FROM push_channelmessagetemplate WHERE `code` = '%s' AND name = '%s';" % (template_code,template_name) print(sql) logger_message.loginfo(u"%s\t方法名:%s\t模版名称:%s\t模版编号:%s"%(send_time,template_name,template_code)) result=database.query(sql) print(result) if len(result) == 1: print('存在模版:%s'%template_name) logger_message.loginfo(u"%s\t方法名:%s模版信息:%s"%(send_time,sys._getframe().f_code.co_name,result)) sql="DELETE FROM push_channelmessagetemplate WHERE `code` = '%s';" % template_code database.query(sql) else: print('不存在模版:%s'%template_name) logger_message.loginfo(u"%s\t方法名:%s模版信息:%s"%(send_time,sys._getframe().f_code.co_name,result)) except Exception as is_check_template_Error: Screenshot(self,u'模版查询异常') logger_message.loginfo(u"%s\t方法名:%s\t模版查询异常:%s"%(send_time,sys._getframe().f_code.co_name,is_check_template_Error)) logger_message.loginfo(u"%s\t方法名:%s\t模版查询异常:%s"%(send_time,sys._getframe().f_code.co_name,is_check_template_Error)) raise
def is_check_message_template(self): u'''短信渠道模版参数化''' time.sleep(1) self.browser.find_element_by_xpath( ".//*[@id='select2-dxSel-container']").click() self.browser.implicitly_wait(5) csv_template = csv_search.csv_test( filename=Push_Template_path().push_template, indexs=1) check_template = csv_template[1] Message_Template = is_pull_down_list( self, csv_template[1], ".//*[@id='select2-dxSel-results']/li[%s]") try: template_name = self.browser.find_element_by_xpath( ".//*[@id='select2-dxSel-container']").text if template_name in str(check_template): logger_message.loginfo('短信模版:%s' % check_template) self.browser.find_element_by_xpath(".//*[@id='%s']" % csv_template[8]).send_keys( csv_template[9]) self.browser.find_element_by_xpath(".//*[@id='%s']" % csv_template[10]).send_keys( csv_template[11]) logger_message.loginfo(u'%s\t方法名:%s\t短信模版') elif template_name in str(check_template): logger_message.loginfo('短信模版:%s' % check_template) self.browser.find_element_by_xpath(".//*[@id='%s']" % csv_template[8]).send_keys( csv_template[9]) self.browser.find_element_by_xpath(".//*[@id='%s']" % csv_template[10]).send_keys( csv_template[11]) self.browser.find_element_by_xpath(".//*[@id='%s']" % csv_template[12]).send_keys( csv_template[13]) except Exception as is_check_message_template_data_error: Screenshot(self, u'短信模版-异常') print(u"%s\t方法名:%s\t短信模版-异常:%s" % (send_time, sys._getframe().f_code.co_name, is_check_message_template_data_error)) logger_message.logwarning( u"%s\t方法名:%s\t短信模版-异常:%s" % (send_time, sys._getframe().f_code.co_name, is_check_message_template_data_error))
def is_Query_Channel_Template(self): u'''渠道模版查询''' try: template_message = csv_search.csv_test( filename=Push_Template_path().push_template, indexs=1) time.sleep(1) self.browser.implicitly_wait(10) self.browser.find_element_by_xpath('.//*[@id="query"]').click() self.browser.implicitly_wait(5) self.browser._switch_to.default_content() self.browser.switch_to.frame( self.browser.find_element_by_tag_name("iframe")) time.sleep(0.5) self.browser.switch_to.frame( self.browser.find_element_by_id("layui-layer-iframe2")) self.browser.find_element_by_xpath('.//*[@id="name"]').send_keys( template_message[1]) self.browser.find_element_by_xpath( './/*[@data-id="channelId"]').click() Channel_type = is_pull_down_list( self, template_message[3], ".//*[@class='dropdown-menu inner']/li") print('%s\t方法名:%s\t模版名称:%s\t渠道类型:%s' % (send_time, sys._getframe().f_code.co_name, template_message[1], template_message[3])) logger_message.loginfo('%s\t方法名:%s\t模版名称:%s\t渠道类型:%s' % (send_time, sys._getframe().f_code.co_name, template_message[1], template_message[3])) time.sleep(1) self.browser.implicitly_wait(5) self.browser._switch_to.default_content() self.browser.switch_to.frame( self.browser.find_element_by_tag_name("iframe")) #返回iframe页面 self.browser.implicitly_wait(5) self.browser.find_element_by_xpath( './/*[@id="layui-layer2"]/div[2]/a[1]').click() except Exception as is_Query_Channel_Template_error: Screenshot(self, u'渠道模版查询异常') print(u"%s\t方法名:%s\t渠道模版查询异常:%s" % (send_time, sys._getframe().f_code.co_name, is_Query_Channel_Template_error)) logger_message.logwarning( u"%s\t方法名:%s\t渠道模版查询异常:%s" % (send_time, sys._getframe().f_code.co_name, is_Query_Channel_Template_error)) raise
def is_add_channel_template(self): u'''添加csv文件新增渠道模版''' try: template_message=csv_search.csv_test(filename=Push_Template_path().push_template,indexs=3) time.sleep(0.5) self.browser.implicitly_wait(10) self.browser.find_element_by_xpath('.//*[@id="add"]').click() self.browser.implicitly_wait(5) self.browser._switch_to.default_content() self.browser.switch_to.frame(self.browser.find_element_by_tag_name("iframe")) time.sleep(0.5) self.browser.switch_to.frame(self.browser.find_element_by_id("layui-layer-iframe2")) self.browser.find_element_by_xpath('//*[@id="name"]').send_keys(template_message[1]) #模版名称:Name self.browser.implicitly_wait(5) self.browser.find_element_by_xpath('//*[@id="%s"]'%template_message[2]).click() #模版状态:State,tmp-disable:禁用,tmp-enable:启用 self.browser.implicitly_wait(5) self.browser.find_element_by_xpath('//*[@data-id="channelId"]').click() self.browser.implicitly_wait(5) is_pull_down_list(self,template_message[3],".//*[@id='query-form']/div[3]/div/div/div/div/ul/li") #渠道名称:ChannelId self.browser.implicitly_wait(5) self.browser.find_element_by_xpath('.//*[@id="code"]').send_keys(template_message[5]) #模版编号:Code self.browser.implicitly_wait(5) self.browser.find_element_by_xpath('.//*[@id="content"]').send_keys(template_message[6]) #模版内容:Content self.browser.implicitly_wait(5) # self.browser.find_element_by_xpath('.//*[@id="escapeContent"]').send_keys(template_message[7]) #转义模版:EscapeContent # logger_message.loginfo('\n%s\n新增模版名称:%s\n模版状态:%s\n渠道名称:%s\n模版编号:%s\n模版内容:%s\n转义模版:%s'% # (send_time,template_message[1],template_message[2],template_message[3],template_message[5],template_message[6],template_message[7])) self.browser.implicitly_wait(5) self.browser.find_element_by_xpath('.//*[@id="btn-add"]').click() is_Sys_Prompt(self) except Exception as is_add_channel_template_error: Screenshot(self,u'添加csv文件新增短信渠道模版-异常') print(u'%s\t方法名:%s\t添加csv文件新增短信渠道模版-异常:%s' % (send_time,sys._getframe().f_code.co_name,is_add_channel_template_error)) logger_message.logwarning(u'%s\t方法名:%s\t添加csv文件新增短信渠道模版-异常:%s' % (send_time,sys._getframe().f_code.co_name,is_add_channel_template_error)) raise
def is_tab_wechat_mobel(self): u"""微信模版推送""" try: template_message=csv_search.csv_test(filename=Push_Template_path().push_template,indexs=3) type_choose=self.browser.find_element_by_xpath('//li[@data-id="5"]') #选择内容类型:模版 AC(self.browser).click(type_choose).perform() self.browser.implicitly_wait(10) template_name=self.browser.find_element_by_xpath(".//*[@id='select2-wxSel-container']").text self.browser.find_element_by_xpath('//span[@title="%s"]'%template_name).click() self.browser.implicitly_wait(5) is_pull_down_list(self,template_message[1],'//ul[@class="select2-results__options"]/li') #send_keys 移动至底 for i in range(5): self.browser.find_element_by_class_name("ps-scrollbar-y").send_keys(Keys.PAGE_DOWN) time.sleep(1) #微信模版 self.browser.find_element_by_id(template_message[8]).send_keys(template_message[9]) self.browser.find_element_by_id(template_message[10]).send_keys(template_message[11]) self.browser.find_element_by_id(template_message[12]).send_keys(template_message[13]) self.browser.find_element_by_id(template_message[14]).send_keys(template_message[15]) time.sleep(2) # self.browser.find_element_by_id("wechat-send").click() # time.sleep(1) # send_result=self.browser.find_element_by_class_name("layui-layer-content").text # text="发送成功" # self.assertEqual(text,send_result, msg="失败的原因:%s != %s" %(text,send_result)) except Exception as wechat_mobel_msg: print(wechat_mobel_msg) logger_message.logwarning(wechat_mobel_msg) raise