def setUp(self): conf1 = Config("YamlFile") confFile = conf1.get_configPath("borkeryaml") brokeryaml = SystemOs().sys_path(confFile) data = yamlUtil(brokeryaml).get_yalm() # print(data) self.driver = Capability(data).app_driver()
def logger(self): """ 封装一个记录的日志方法 :return: """ # 创建一个logger logger = logging.getLogger("myLogger") logger.setLevel(logging.DEBUG) # 创建一个handler,用于写入日志文件 conf = Config("FilePath") log_path=conf.get_path_config(self.logs) log_file = logging.FileHandler(SystemOs().sys_path(log_path)) log_file.setLevel(logging.DEBUG) # 再创建一个handler,用于输出到控制台 console = logging.StreamHandler() console.setLevel(logging.DEBUG) # 定义handler的输出格式 formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') log_file.setFormatter(formatter) console.setFormatter(formatter) # 给logger添加handler logger.addHandler(log_file) logger.addHandler(console) return logger
def childConfigXML(self, Pageskeyword, UIElementkeyword): confFile = self.rootChildConfigPath() config2 = Config("XMLFilePath", confFile) filepath = config2.get_path_config("uigoods") filepath = SystemOs().sys_path(filepath) xmlspath = XmlUtil(filepath) # 获取XML中相关信息 xmls = xmlspath.xml_parsing(Pageskeyword, UIElementkeyword) return xmls
def childConfigXlsx(self,sheet,dictData): # "获取子配置文件中信息",loginXlsx confFile = self.rootChildConfigPath() config1= Config("XlsxFilePath",confFile) loginXlsx = config1.get_path_config("user_login") loginXlsx = SystemOs().sys_path(loginXlsx) #dictData = {"userName": 3, "password": 4, "expected": 6} excelUtil = DoExcel(loginXlsx, sheet).do_excel(**dictData) return excelUtil
def childCofigLeading_inEcxel(self): """ 导入虚拟文件模板 :return: """ confFile = self.rootChildConfigPath() config5 = Config("XlsxFilePath", confFile) Leading_inEcxel = config5.get_path_config("redeem_code_template") return Leading_inEcxel
def childConfigPublicImg(self): """ 获取公共上传图片地址 :return: """ confFile = self.rootChildConfigPath() config4 = Config("PublicImg", confFile) public_img = config4.get_path_config("goodsImg") return public_img
def childConfigXlsx(self, sheet, dictData): # "获取子配置文件中信息",Excel文件内容 confFile = self.rootChildConfigPath() config1 = Config("XlsxFilePath", confFile) goodsObjectXlsx = config1.get_path_config("goods_object") goodsObjectXlsx = SystemOs().sys_path(goodsObjectXlsx) excelUtil = DoExcel(goodsObjectXlsx, sheet).do_excel(**dictData) return excelUtil
def childConfigImgPath(self): """ 获取图片路径,并新建以日期为基础的文件目录名 例如: img/2019-01-01/ :return: """ confFile = self.rootChildConfigPath() config3 = Config("ImgPath", confFile) img_path = config3.get_path_config("error_img") data_path = TestDateTime().local_day() img_path = SystemOs().sys_path(img_path, data_path) SystemOs().mkdirs_file(img_path) return img_path
def get_configMySql(self): conf= Config('MySqlDB') self.host = conf.get_mysqldb("db_host") self.uname = conf.get_mysqldb("db_user") self.passwd = conf.get_mysqldb("db_pwd") self.sqltable = conf.get_mysqldb("db_table") self.port = int(conf.get_mysqldb("db_port"))
def rootChildConfigPath(self): # 从主配置文件中获取子配置文件路径 conf2 = Config("ConfigKIDs") # 获取子文件路径 confFile = conf2.get_configPath("markerting_points_configs") return confFile
def rootConfigURL(self): # 从主配置文件Config中获取URL conf1 = Config("URL") url = conf1.get_url_config("marketing") return url
def childConfigTestFile(self): # "获取子配置文件中信息",testFile confFile = self.rootChildConfigPath() config1 = Config("TestFile", confFile) testFile = config1.get_path_config("mprTestFile") return testFile
def childConfigReport(self): # "获取子配置文件中信息",report confFile = self.rootChildConfigPath() config1= Config("ReportFile",confFile) mpreport= config1.get_path_config("mpReport") return mpreport
def get_configMongoDb(self): conf = Config('MongoDB') self.host = conf.get_mongodb("mongo_host") self.port = conf.get_mongodb("mongo_port") self.mongodb = conf.get_mongodb("mongo_db") self.mongo_mycol = conf.get_mongodb("mongo_mycol")