Exemplo n.º 1
0
    def __init__(self, case_id, rely_case_id, **kwargs):
        '''
        操作数据依赖  \n
        之前是需要传入sheet name,而现在不需要,可以直接读取ini配置即可。
        :param case_id: 当前的case id
        :param rely_case_id: 依赖的caseid
        :param sheetname: sheet表的名称,这个字段将不再进行参数传递,而是直接通过 ini的配置文件进行读取。
        :param kwargs: sheet表的数据,双层dict,外层的dict的key为 caseid;内层dict为每一行的值。
        '''
        self.case_id = case_id
        # 接收传入的依赖的case id
        self.rely_case_id = rely_case_id
        # # 用于读取request的json文件。该文件的名称与sheet表的名称一致。
        # self.sheet_name = sheetname
        # 传入整个sheet表的值,为双层dict
        self.data_dict = kwargs
        # 获取excel表的表头映射
        self.etm = ExcelTitleMapping()

        # 调用所有目录的绝对路径值类
        self.get_each_dir_path = GetEachDirPath()
        # # 拼接request 请求的 json文件路径
        # self.json_file_path = self.get_req_json_file_path()
        # # 获取request请求的json文件中的所有值
        # self.req_data = GetReqData(self.json_file_path)
        # json file path 已经自动获取,不需要进行参数传递。
        self.req_data = GetReqData()
Exemplo n.º 2
0
 def __init__(self):
     ''''''
     file_name = self.__file_name
     file_dir = GetEachDirPath().get_config_dir()
     self.config_file_path = GetFilePath().get_file_path_ini(file_dir, file_name)
     self.config = configparser.ConfigParser()
     self.config.read(self.config_file_path, 'utf-8')
Exemplo n.º 3
0
    def read_json_file(self, filename):
        '''
        读取json文件,并将数据转化为dict,针对文件句柄,是直接从文件中读取  \n
        :param filename: 文件名
        :return: 转化后的dict
        '''
        dir_path = GetEachDirPath()
        file_path = GetFilePath()
        # 获取依赖的数据所在的目录
        data_dir = dir_path.get_data_request_dir()
        # 拼接数据目标文件路径(启文件名称)
        json_file = file_path.get_file_path_json(data_dir, filename)
        # 获取json文件数据
        with open(json_file, 'r', encoding='utf-8') as fp:
            return json.load(fp)


# help(OperaJsonFile)
Exemplo n.º 4
0
 def __init__(self):
     '''
     进行实例化时,会进行如下操作:  \n
     1:获取保存cookie数据的目录  \n
     2:实例化获取文件path对象  \n
     3:实例化操作json文件对象  \n
     '''
     self.cookie_dir = GetEachDirPath().get_data_cookie_dir()
     self.file_path = GetFilePath()
     self.opera_file = OperaJsonFile()
Exemplo n.º 5
0
    def get_json_file_path(self):
        '''
        获取request 请求对应的json文件路径(启文件名称)  \n
        :return: 获取request 请求对应的json文件路径(启文件名称)
        '''
        sheetname = GetConfigFileData().get_excel_sheet_name()
        json_dir = GetEachDirPath().get_data_request_dir()
        json_path = GetFilePath().get_file_path_json(json_dir, sheetname)
        return json_path


# help(GetReqData)
Exemplo n.º 6
0
@File:save_screenshot.py
@Description: 
1.
2.
@Modify Time:  
@Modify Description: 
1.
2.
"""
import sys

sys.path.append('../../')
from common.util.get_each_dir_abspath import GetEachDirPath
from common.util.get_file_path import GetFilePath

img_dir = GetEachDirPath().get_img_dir()

HTML_IMG_TEMPLATE = """【{}】--双击/右键新标签页看大图:<img src="data:image/png;base64, {}" width="400px" height="225px" style="border:1px solid blue" onclick="show_img(this)"/>"""


class SaveScreenShot():
    '''进行截图 base64 直接保存到html中 或 保存为png格式,直接存放于 img目录下'''

    def save_browser_img(self, driver, img_name):
        """
        保存图片,需要传入驱动、图片路径、图片名称  \n
        :param driver: 驱动
        :param img_name: 图片名称
        :return: None
        """
        driver = driver
Exemplo n.º 7
0
from common.excel.opera_rely_data import OperaRelyData
from common.cookie.opera_cookie import OperaCookie
# from common.excel.get_match_data import GetMatchData
from common.util.response_json_to_str import ResJsonToStr
from common.util.run_case import RunCase

'''
需要注意的是:
1:这里在获取excel的数据时,是需要传入excel的路径的。
2:该路径可以是绝对路径,也可以相对路径。
3:如果是相对路径,必须是调用/执行 该case(test_login.py)文件(runall.py)的相对路径,而不是相对于 test_login.py文件的相对路径
4:建议传入绝对路径,即获取当前 test_login.py的路径,然后再进行拼接。
'''

config_data = GetConfigFileData()
dir_path = GetEachDirPath()
file_path = GetFilePath()
# 想要读取的excel表的名称
excel_name = config_data.get_excel_name()
# sheet表的名称
sheet_name = config_data.get_excel_sheet_name()
# 获取excel所在的目录
excel_dir = dir_path.get_case_data_dir()
# 获取excel的路径(含名称)
excel_path = file_path.get_file_path_xlsx(excel_dir, excel_name)

excel_data = ReadExcelData(excel_path, sheet_name)
excel_list = excel_data.get_sheet_data_list()
excel_dict = excel_data.get_sheet_data_dict()

json_file_dir = dir_path.get_data_request_dir()
Exemplo n.º 8
0
# from BeautifulReport import BeautifulReport
import unittest
import sys
import os

sys.path.append('../')
from common.util.get_each_dir_abspath import GetEachDirPath
from common.mail.send_mail import SendMail
from common.util.get_file_path import GetFilePath
from common.util.get_time import GetTime
from common.report.BeautifulReport_Single import BeautifulReport
from common.config.read_config_data import GetConfigFileData

# 获取相应的路径,文件名称规则。
dir = GetEachDirPath()
file_path = GetFilePath()
config = GetConfigFileData()

case_dir = dir.get_case_dir()
excel_dir = dir.get_case_data_dir()
report_dir = dir.get_report_dir()
img_dir = dir.get_img_dir()
req_json_dir = dir.get_data_request_dir()
config_dir = dir.get_config_dir()

# 从配置文件里获取相关的配置信息
case_name_rule = config.get_case_name_rule()
report_name = config.get_report_html_name()
report_title = config.get_report_title()
Exemplo n.º 9
0
from common.util.get_each_dir_abspath import GetEachDirPath
from common.util.get_time import GetTime

# 获取当前时间
cur_time = GetTime().get_cur_time()

config = GetConfigFileData()
# 获取要运行的浏览器
browser = config.get_driver_browser()
# 获取驱动 exe
chrome_driver_exe = config.get_driver_chrome_exe_name()
firefox_driver_exe = config.get_driver_firefox_exe_name()
ie_driver_exe = config.get_driver_ie_exe_name()

# 获取driver相关的目录,及日志输出目录
driver_log_dir = GetEachDirPath().get_driver_log_dir()
driver_dir = GetEachDirPath().get_driver_dir()

# 设置浏览器驱动exe的路径
chrome_exe_path = GetFilePath().get_file_path_exe(driver_dir, chrome_driver_exe)
firefox_exe_path = GetFilePath().get_file_path_exe(driver_dir, firefox_driver_exe)
ie_exe_path = GetFilePath().get_file_path_exe(driver_dir, ie_driver_exe)

# 设置各浏览器驱动输出的log名称
chrome_log_name = 'chrome_log' + cur_time
firefox_log_name = 'firefox_log' + cur_time
ie_log_name = 'ie_log' + cur_time


# 设置各浏览器的log路径
chrome_log_path = GetFilePath().get_file_path_log(driver_log_dir, chrome_log_name)