def __init__(self, excelfilename): self.excelfilename = excelfilename fc = FileChecK() boolean = fc.is_has_file(excelfilename) if boolean: self.excel_path = fc.get_fileabspath() self.logger = LogObj()
def RunBrowser(baseURL): fc = FileChecK() boolean = fc.is_has_file("RunWhichBrowser.ini") if boolean: rwb_ini_path = fc.get_fileabspath() conf = Config(rwb_ini_path) runBrowser = conf.get("run", "browser") LogObj().debug("======本次试用%s浏览器进行测试======" % runBrowser) driver = WebDriverDoBeforeTest().getDriverTooler(runBrowser, baseURL) return driver
def __init__(self): self.conf = ConfigParser.ConfigParser() self.__fileabspath = None self.__projectpath = None self.__logger = LogObj() fc = FileChecK() boolean = fc.is_has_file("driverpath.conf") if boolean: self.__fileabspath = fc.get_fileabspath() self.__projectpath = fc.getProjectPath() self.conf.read(self.__fileabspath)
def __init__(self, driver): fc = FileChecK() boolean = fc.is_has_file("framework.ini") if boolean: self.projectpath = fc.getProjectPath() self.fwInipath = fc.get_fileabspath() self.conf = Config(self.fwInipath) self.capturePath = os.path.join( self.projectpath, self.conf.get("capturePath", "capturePath")) self.pauseTime = self.conf.get("TimeSet", "pauseTime") self.logger = LogObj() self.driver = driver
def __init__(self): fc = FileChecK() boolean = fc.is_has_file("framework.ini") if boolean: rwb_ini_path = fc.get_fileabspath() conf = Config(rwb_ini_path) baseURL = conf.get("baseURL", "baseURL") self.driver = RunBrowser(baseURL) self.driverapi = WebdriverApi(self.driver) self.logger = LogObj() self.basecase = WebDriverDoBeforeTest() self.basecase.driver = self.driver
def __init__(self): self.fc = FileChecK() bools = self.fc.is_has_file("email.ini") if bools: fp = self.fc.get_fileabspath() conf = Config(fp) self.smtp_host = conf.get("emails", "smtp_host") self.pop3_host = conf.get("emails", "pop3_host") self.receiver = conf.get("emails", "receiver").split(",") self.receiver_pa = conf.get("emails", "receiver_pa") self.sender = conf.get("emails", "sender") self.sender_pa = conf.get("emails", "sender_pa") self.logger = LogObj()
def __init__(self): self.__GBD = GetBrowserDriver() self.__logger = LogObj() self.driver = None fc = FileChecK() boolean = fc.is_has_file("framework.ini") if boolean: self.inipath = fc.get_fileabspath() self.fw_conf = Config(self.inipath) self.waitTimeout = self.fw_conf.get("TimeSet", "waitTimeout") self.scriptTimeout = self.fw_conf.get("TimeSet", "scriptTimeout") self.pageLoadTimeout = self.fw_conf.get("TimeSet", "pageLoadTimeout")
def __init__(self): self.logger = LogObj() self.fc = FileChecK() boolean = self.fc.is_has_file("db.ini") if boolean: self.inipath = self.fc.get_fileabspath() self.conf = Config(self.inipath) self.host = str(self.conf.get("dbset", "host")) self.port = int(self.conf.get("dbset", "port")) self.user = str(self.conf.get("dbset", "user")) self.passwd = str(self.conf.get("dbset", "passwd")) self.db = str(self.conf.get("dbset", "db")) self.charset = str(self.conf.get("dbset", "charset")) self.conn = MySQLdb.Connect(self.host, self.user, self.passwd, self.db, self.port, self.charset) self.logger.debug("数据库初始化完成" + self.host + str(self.port) + self.db + self.charset)
def __init__(self): self.driver = None self.className = None self.beforeSuiteStarts = 0 self.afterSuiteStops = 0 self.beforeClassStarts = 0 self.afterClassStops = 0 self.beforeTestStarts = 0 self.afterTestStops = 0 fc = FileChecK() boolean = fc.is_has_file("framework.ini") if boolean: self.projectpath = fc.getProjectPath() self.fwInipath = fc.get_fileabspath() self.logger = LogObj() self.capturePath = os.path.join( self.projectpath, Config(self.fwInipath).get("capturePath", "capturePath"))
class Execute_SQL(): def __init__(self): self.logger = LogObj() self.fc = FileChecK() boolean = self.fc.is_has_file("db.ini") if boolean: self.inipath = self.fc.get_fileabspath() self.conf = Config(self.inipath) self.host = str(self.conf.get("dbset", "host")) self.port = int(self.conf.get("dbset", "port")) self.user = str(self.conf.get("dbset", "user")) self.passwd = str(self.conf.get("dbset", "passwd")) self.db = str(self.conf.get("dbset", "db")) self.charset = str(self.conf.get("dbset", "charset")) self.conn = MySQLdb.Connect(self.host, self.user, self.passwd, self.db, self.port, self.charset) self.logger.debug("数据库初始化完成" + self.host + str(self.port) + self.db + self.charset) def execute_select(self, sql): cursor = self.conn.cursor() try: cursor.execute(sql) self.logger.debug("check_acct_available :" + sql) res = cursor.fetchall() if len(res) < 1: self.logger.error("%s执行查询内容不存在" % sql) return res finally: cursor.close() return None def execute_addone(self, sql): cursor = self.conn.cursor() #操作数据库的游标 try: cursor.execute(sql) #执行sql语句 if cursor.rowcount == 1: self.logger.debug("%s添加成功" % sql) self.conn.commit() #执行成功后向数据库进行提交 return True except Exception, e: self.conn.rollback() self.logger.error("插入数据出现错误" + str(e)) finally:
def html_reporter(): logger = LogObj() fc = FileChecK() pro_path = fc.getProjectPath() boolean = fc.is_has_file("framework.ini") if boolean: inipath = fc.get_fileabspath() fw_conf = Config(inipath) htmlrp_path = fw_conf.get("htmlreportPath", "htmlreportPath") htmreportl_abs_path = os.path.join(pro_path,htmlrp_path) timecurrent = DateTimeManager().formatedTime("%Y-%m-%d-%H-%M-%S") logger.debug("=====创建了一个html文件报告,路径是::"+htmreportl_abs_path) if not os.path.exists(htmreportl_abs_path): os.makedirs(htmreportl_abs_path) file_path = str(htmreportl_abs_path)+timecurrent+"-LDP-TestingRreporter.html" try: if os.path.exists(file_path): html_obj = open(file_path,"a") #打开文件 追加 return html_obj else: html_obj = file(file_path,"wb+") return html_obj except Exception,e: logger.error("创建html_reporter出现错误"+str(e))
class Emails(): def __init__(self): self.fc = FileChecK() bools = self.fc.is_has_file("email.ini") if bools: fp = self.fc.get_fileabspath() conf = Config(fp) self.smtp_host = conf.get("emails", "smtp_host") self.pop3_host = conf.get("emails", "pop3_host") self.receiver = conf.get("emails", "receiver").split(",") self.receiver_pa = conf.get("emails", "receiver_pa") self.sender = conf.get("emails", "sender") self.sender_pa = conf.get("emails", "sender_pa") self.logger = LogObj() def SendEmail_IsHTML(self): latestfpath, fname, currentfolder = self.fc.get_LatestFile() msgRoot = MIMEMultipart('related') ff = open(latestfpath, 'rb') message = MIMEText(ff.read(), 'html', 'utf-8') ff.close() message['From'] = self.sender #message['To'] = self.receiver subject = '实验室数字化平台-自动化测试报告' message['Subject'] = Header(subject, 'utf-8') msgRoot.attach(message) try: smtpObj = smtplib.SMTP() smtpObj.connect(self.smtp_host) smtpObj.login(self.sender, self.sender_pa) smtpObj.sendmail(self.sender, self.receiver, msgRoot.as_string()) self.logger.debug("SendEmail_withFile邮件发送成功") smtpObj.close() except Exception, e: print e self.logger.error("Error: 无法发送邮件::" + str(e))
# -*- coding:UTF-8 -*- ''' Created on 2016年5月12日 @author: jayzhen ''' from com.framework.util.FileCheckAndGetPath import FileChecK from com.framework.util.ConfigCommonManager import Config fc = FileChecK() b = fc.is_has_file("email.ini") if b: fp = fc.get_fileabspath() c = Config(fp) cc = c.get("emails", "receiver") print cc ee = cc.split(",") print type(ee) print type(cc)