Skip to content

Commit

Permalink
Merge pull request #316 from NiceProjectPoland/Test-#195-for-Issue-#37
Browse files Browse the repository at this point in the history
Test case for Issue #37 - Verify xlsx report content
  • Loading branch information
damies13 authored Oct 27, 2024
2 parents e0a6a89 + b792264 commit cc66a85
Show file tree
Hide file tree
Showing 84 changed files with 793 additions and 172 deletions.
1 change: 1 addition & 0 deletions Tests/Regression/Reporter/GUI_Bugs.robot
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ Template with Start and End Dates

${EndTime}= Get Text Value To Right Of EndTime
${EndTime}= Replace String ${EndTime} 03:03 03:02
Wait For Status PreviewLoaded
Set Text Value To Right Of EndTime ${EndTime}
# Take A Screenshot

Expand Down
3 changes: 2 additions & 1 deletion Tests/Regression/Reporter/GUI_Common.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Library ImageHorizonLibrary reference_folder=${IMAGE_DIR}
Library OCRLibrary

Library read_docx.py
Library read_xlsx.py

*** Variables ***
${default_image_timeout} ${120}
Expand Down Expand Up @@ -613,4 +614,4 @@ Navigate to and check Desktop Icon For Ubuntu



#
#
885 changes: 715 additions & 170 deletions Tests/Regression/Reporter/GUI_Features.robot

Large diffs are not rendered by default.

Binary file modified Tests/Regression/Reporter/Images/file_method/macos_finder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/Regression/Reporter/Images/file_method/macos_launchpad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion Tests/Regression/Reporter/pip_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ opencv-python
Pillow
robotframework-ocrlibrary
clipboard
python-docx
python-docx
openpyxl
openpyxl_image_loader
pandas
71 changes: 71 additions & 0 deletions Tests/Regression/Reporter/read_xlsx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import os

from openpyxl import load_workbook
from openpyxl_image_loader import SheetImageLoader
from pandas import read_excel


def read_all_xlsx_sheets(xlsx_path: str) -> list:
return load_workbook(xlsx_path, keep_links=False).sheetnames


def read_all_xlsx_text_data(xlsx_path: str) -> list:
"""
Read all xlsx text data from all sheets.
"""
wb = load_workbook(xlsx_path, keep_links=False)

xlsx_tables = []
for sheet in wb.sheetnames:
sheet_content = read_xlsx_text_data_from_sheet(xlsx_path, sheet)
xlsx_tables.append(sheet_content)

print(xlsx_tables)
return xlsx_tables


def read_xlsx_text_data_from_sheet(xlsx_path: str, sheet_name: str) -> list:
"""
Read xlsx text data from given xlsx sheet.
"""
all_excel_data_frame = read_excel(xlsx_path, sheet_name, keep_default_na=False, na_values=['NaN'])
excel_data_list = all_excel_data_frame.values.tolist()

for row_n in range(len(excel_data_list) - 1, -1, -1):
for cell_n in range(len(excel_data_list[row_n]) - 1, -1, -1):
if excel_data_list[row_n][cell_n] == "":
excel_data_list[row_n].pop(cell_n)

if len(excel_data_list[row_n]) == 0:
excel_data_list.pop(row_n)

return excel_data_list


def extract_image_from_xlsx_sheet(xlsx_path: str, xlsx_sheet: str, cell_id: str, output_folder: str, show_image: bool = False):
"""
Extract an image from XLSX file from a given cell in specified sheet.
Returns name of the saved image.
"""
wb = load_workbook(xlsx_path, keep_links=False)
sheet = wb[xlsx_sheet]
try:
image_loader = SheetImageLoader(sheet)
except Exception as e:
raise AssertionError("Error in SheetImageLoader:", e)
try:
image = image_loader.get(cell_id)
except Exception as e:
print(f"Cell {cell_id} doesn't contain an image. Exception: {e}")
return 0
if show_image:
image.show()
img_name = (xlsx_sheet + "_" + cell_id + "_image.png").replace(" ", "_")

if not os.path.exists(output_folder):
os.makedirs(output_folder)

image.save(os.path.join(output_folder, img_name))
print(f"XLSX RFSwarm raport image saved as: {img_name}")

return img_name
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cc66a85

Please sign in to comment.