Пример #1
0
 def Warning_PopUp_TXT(self, UseCase_Number, Popup_Name):
     """
     获取警告窗口的文本信息
     :return:
     """
     from config.relative_location import path
     atLast_actuals = None
     relativeAddress = path.location()  # 获取项目相对位置
     app = Application().connect(title_re=Popup_Name)
     dlg_spec = app.window(title=Popup_Name)
     # 切换到文本信息窗口
     dlg_spec1 = dlg_spec.DirectUIHWND
     # 获取预期值
     location = relativeAddress + r"src\testCase\d_useCase_screenshot\expectScreenshots\\" + UseCase_Number + ".png"
     time.sleep(0.5)
     dlg_spec1.capture_as_image().save(location)  # 获取警告弹窗的文本截图
     actuals = pictureProcessing(location).screenshot()  # 读取截图中的文本
     if "」OK" in actuals:
         atLast_actuals = re.sub("」OK", '', actuals)
     elif "OK" in actuals:
         atLast_actuals = re.sub("OK", '', actuals)
     elif "确定取消" in actuals:
         atLast_actuals = re.sub("确定取消", '', actuals)
     else:
         atLast_actuals = actuals
     dlg_spec.child_window(title="OK", class_name="Button")  # 关闭弹窗
     return atLast_actuals
Пример #2
0
 def clear_AllowableCurve(self):
     """
     清除所有的许用值曲线
     :return:
     """
     from OperatingControls.enterModule import specialWay_OperatingControls, ctrW_AeroAerochcek
     from config.relative_location import path
     from PIL import Image
     from PIL import ImageChops
     relativeAddress = path.location()  # 获取相对位置
     operationWindow = "编辑材料许用值"
     self.dict["所在模块"] = "材料信息->定义复合材料参数"
     module = "Aerobook-Aerocheck"
     aero_window, son_window = pywin_openAProgram(module).menuOpen(
         self.dict)
     specialWay_OperatingControls(operationWindow).uia_OperatingControls()
     module_window = ctrW_AeroAerochcek(
         son_window).workField_composite_information()
     dlg_spec = module_window.child_window(title="GridWindow",
                                           class_name="wxWindowNR")
     # 进行图片对比,来判断材料许用值曲线表是否为空
     # 预期截图位置location_expect
     location_expect = relativeAddress + r"src\testCase\d_useCase_screenshot\Aerocheck\expectScreenshots\aaa.png"
     # 实际截图位置
     location_actual = relativeAddress + r"src\testCase\d_useCase_screenshot\Aerocheck\ActualScreenshots\\" + "实际材料许用值曲线表截图.png"
     while True:
         # 判断实际值截图是否存在,如果存在就删掉
         result = os.path.exists(location_actual)
         if result:  # 如果存在就删除实际图片
             os.remove(location_actual)
         dlg_spec.capture_as_image().save(location_actual)  # 截取实际值图片
         # 对比截图
         image_one = Image.open(location_expect)
         image_two = Image.open(location_actual)
         diff = ImageChops.difference(image_one, image_two)
         if diff.getbbox() is None:  # 如果图片一样,就说明材料许用值曲线表里没有内容
             break
         else:  # 如果不图片一样,就说明材料许用值曲线表里有内容,就删除内容
             i = 1
             dlg_spec.right_click_input(coords=(10, 10))  # 点击鼠标右键
             from pykeyboard import PyKeyboard  # 选择删除按钮
             # 选择右键下拉框的“独立显示”
             k = PyKeyboard()
             while i <= 2:
                 k.press_key(k.down_key)
                 time.sleep(0.5)
                 i = i + 1
             k.press_key(k.enter_key)
             # 删除实际截图
             result = os.path.exists(location_actual)
             if result:  # 如果存在就删除实际图片
                 os.remove(location_actual)
Пример #3
0
 def expect_dataProcessing(self, dictSet, listt_dicti_actual):
     """
    预期值格式处理,用于实际值跟预期值对比的时候,保证对比的格式准确
    :return: 预期值字典;如果有“控件截图”类型的检查,就返回预期值图片的位置
     """
     dict_expect = {}
     path_value = None
     messageType = dictSet["预期值信息类型"]
     expect_result = dictSet["预期结果文本信息"]
     #   去掉预期结果前后的空格
     if expect_result:  # 如果预期值不为空
         expect_result = expect_result.strip()  # 去掉预期值,前后的空格
     # 字符串转化成列表
     if ";" in messageType:  # 如果预期值信息类型值中有“;”,就说明有多个检查类型
         messageType = messageType.split(";")
         if ";" in expect_result:  # 如果预期值信息类型值中有“;”,就说明有多个检查类型
             expect_result = expect_result.split(";")
     # 把两个列表和成字典
     if type(messageType) == list and type(
             expect_result) == list:  #  如果“预期值信息类型”和“预期结果文本信息”都是列表
         dict_expect = dict(zip(messageType,
                                expect_result))  #  就把两个列表合成一个字典
     elif type(messageType) == str and type(expect_result) == str:
         dict_expect = {messageType: expect_result}
     else:
         from tool import MyException
         raise MyException("预期值信息类型和预期结果文本信息不匹配,预期值信息类型:%r;预期结果文本信息:%r" %
                           (type(messageType), type(expect_result)))
     if "控件截图" in dict_expect:  # 控件截图如果在“预期值信息类型”里
         # 获取“预期值信息类型”中“控件截图”详细的地址
         location = dict_expect["控件截图"]
         relativeAddress = path.location()  # 获取项目相对位置
         path_value = relativeAddress + location
         # 把预期结果放入,预期值字典中
         dict_expect["控件截图"] = "图片一样"
     return dict_expect, path_value
Пример #4
0
 def start_Aerobook_Aercheck(self):
     """
     启动Aerobook_Aercheck
     :param self:
     :return:
     """
     relativeAddress = path.location()  # 获取项目相对位置
     # 初始化项目的存放位置
     sourceDir = relativeAddress + r"src\testCase\projectFile\自动化测试相关文件"  # 项目有关的模板文件
     source = relativeAddress + r"src\testCase\projectFile\automateFile"  # 新建项目的保存地址
     folderFile_dispose(source).delfolder()  # 删除已有的项目文件夹
     folderFile_dispose(sourceDir).copyFile(source)  # 生成新的项目文件夹,并返回文件夹路径
     # 读取配置文档信息里的Aerobook和Aerocheck窗口的标题
     aero_title = ProfileDataProcessing("commonality", "AerobookEdition").config_File()  # 从配置文件获取Aerobook窗口标题
     aerocheck_title = ProfileDataProcessing("commonality", "AerocheckEdition").config_File()  # 从配置文件获取Aerocheck窗口标题
     # 通过AerobookEXE文件启动Aerobook,并进入进入Aerocheck页面
     py_app = pywin_openAProgram().open_accredit()  # 启动Aerobook应用程序
     uia_app = UIA_link().EntrySubapplication("Aerocheck")  # 点击Aerocheck进入Aerocheck页面
     # 新建项目
     ControlOperationSuite_Aercheck(aerocheck_title).childApp_newProject(py_app, "文件->项目->新建", source)
     # 独立显示底部蒙皮
     ControlOperationSuite_Aercheck(py_app).uia_ShowSkinSeparately(aero_title)
     #  修改配置文件内容用于执行用例的时候获取项目所在地址
     ProfileDataProcessing("commonality-Aerobook-Aerocheck", "ProjectSave_path").config_File_amend(source)
Пример #5
0
        @staticmethod
        def getTestFunc(arg1, arg2):
            def func(self):
                self.test_case_1(arg1, arg2)
            return func

def __generateTestCases():
    arglists = [('arg11', 'arg12'), ('arg21', 'arg22'), ('arg31', 'arg32')]
    for args in arglists:
        setattr(Test_test, 'test_func_%s_%s' % (args[0], args[1]),
                Test_test.getTestFunc(*args))



__generateTestCases()






if __name__ == '__main__':
    suite = unittest.TestSuite()
    suite.addTests(unittest.TestLoader().loadTestsFromTestCase(Test_test))
    # suite.addTests(unittest.TestLoader().loadTestsFromTestCase(Test_test111))
    file_name=time.strftime("%Y%m%d%H%M%S")+"铺层库优化测试报告"    # 测试报告名称
    relativeAddress = path.location()
    logPath = relativeAddress+"report//Aerocheck//" # 测试报告保存地址
    result = BeautifulReport(suite).report(filename=file_name,log_path=logPath,description="铺层库优化工作栏")

Пример #6
0
from config.relative_location import path

import os
import shutil

relativeAddress = path.location()  # 获取项目相对位置
target = relativeAddress + r"src\testCase\projectFile\自动化测试相关文件"  # 被复制文件的详细路径
source = relativeAddress + r"\src\testCase\projectFile\automateFile"  # 被复制文件的详细路径

# source_path = os.path.abspath(target)
# target_path = os.path.abspath(source)
#
# if not os.path.exists(target_path):
#     os.makedirs(target_path)
#
# if os.path.exists(source_path):
#     # root 所指的是当前正在遍历的这个文件夹的本身的地址
#     # dirs 是一个 list,内容是该文件夹中所有的目录的名字(不包括子目录)
#     # files 同样是 list, 内容是该文件夹中所有的文件(不包括子目录)
#     for root, dirs, files in os.walk(source_path):
#         for file in files:
#             src_file = os.path.join(root, file)
#             shutil.copy(src_file, target_path)
#             print(src_file)
#
# print('copy files finished!')

# my_file = os.path.isfile(source)  # 判断文件是否存在

print("source:", source)