无法将存储在单元格中的图像文件提取到我需要附加该图像的测试

问题描述 投票:0回答:0

以下是我用来提取存储在 G7 单元格中的图像的代码:

def getImageAttachment():
    ExcelBook = openpyxl.load_workbook("F:\\MSL Automation Framework\\msl.test\\TestDataExcel.xlsx")
    sheet = ExcelBook.active
    image_loader = SheetImageLoader(sheet)
    image = image_loader.get('G7')
    test_ImageAttachment = [{sheet['G6'].value: image}]
    return test_ImageAttachment

但是 TypeError: object of type 'JpegImageFile' has no len() 运行测试时抛出错误。下面附上截图:

下面附上截图,演示存储在 G7 单元格中的图像:

请帮帮我。我不想直接提供图像路径以避免硬编码,而是想从 excel 表中获取图像。

python selenium-webdriver pytest openpyxl ui-automation
© www.soinside.com 2019 - 2024. All rights reserved.