From 3c9b13bba047988ac9cca662099dcc70960650f8 Mon Sep 17 00:00:00 2001 From: Canadian-Ty Date: Tue, 16 Apr 2024 14:08:24 -0400 Subject: [PATCH 1/2] Converter ignores empty rows and added terminator character for column headers. --- tass-converter/src/tass/converter/conf.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tass-converter/src/tass/converter/conf.py b/tass-converter/src/tass/converter/conf.py index 0b820c2..911a217 100644 --- a/tass-converter/src/tass/converter/conf.py +++ b/tass-converter/src/tass/converter/conf.py @@ -48,6 +48,8 @@ def convert_test_case(test_case, conf, wb): tc["title"] = wb[case]['D1'].value tc["steps"] = [] for row in wb[case].iter_rows(min_row=3, max_col=6): + if (row[0] is None or row[0] == ''): + continue print(row) steps = {} parameters = {} @@ -66,7 +68,9 @@ def convert_test_case(test_case, conf, wb): if (col[0].value is not None): header = wb[case].cell(2, col[0].column).value - if (col[0].value is not None and header == 'locator'): + if (header == '//end//'): + break + elif (header == 'locator'): locator = col[0].value.split(',') if (len(locator) == 2): @@ -77,14 +81,13 @@ def convert_test_case(test_case, conf, wb): else: parameters['locator'] = locator[0] - elif (col[0].value is not None and header == 'page'): + elif (header == 'page'): parameters['page'] = col[0].value.split(',', 1) - elif (col[0].value is not None and 'action' in header): + elif ('action' in header): parameters['action'] = col[0].value.split(',', 1) - elif (col[0].value is not None - and header == 'locator_args'): + elif (header == 'locator_args'): parameters['locator_args'] = col[0].value.split(',') else: From d00f8a9f2684cfb49d3e20c2e8f1f320bbfc5aab Mon Sep 17 00:00:00 2001 From: Desjardins Date: Thu, 18 Apr 2024 09:51:48 -0400 Subject: [PATCH 2/2] Fixed bugs with scenario conversion. Added missing fields to page conversion. --- tass-converter/src/tass/converter/conf.py | 16 ++-- .../src/tass/converter/page_conf.py | 83 ++++++++++++++++--- 2 files changed, 82 insertions(+), 17 deletions(-) diff --git a/tass-converter/src/tass/converter/conf.py b/tass-converter/src/tass/converter/conf.py index 911a217..672681f 100644 --- a/tass-converter/src/tass/converter/conf.py +++ b/tass-converter/src/tass/converter/conf.py @@ -10,7 +10,7 @@ def convert(path): conf_file["Test_suites"] = [] conf_file["Test_cases"] = [] conf_file["Steps"] = {} # Will be converted to list later. - wb = openpyxl.load_workbook(path) # Open conf file. + wb = openpyxl.load_workbook(path, data_only=True) # Open conf file. test_run = [] # Holds all test_run worksheet names. test_suite = [] # Holds all test_suite worksheet names. @@ -65,12 +65,14 @@ def convert_test_case(test_case, conf, wb): max_row=row_num, min_col=4): - if (col[0].value is not None): - header = wb[case].cell(2, col[0].column).value + header = wb[case].cell(2, col[0].column).value + + if (header == '//end//'): + break - if (header == '//end//'): - break - elif (header == 'locator'): + if (col[0].value is not None): + + if (header == 'locator'): locator = col[0].value.split(',') if (len(locator) == 2): @@ -88,7 +90,7 @@ def convert_test_case(test_case, conf, wb): parameters['action'] = col[0].value.split(',', 1) elif (header == 'locator_args'): - parameters['locator_args'] = col[0].value.split(',') + parameters['locator_args'] = str(col[0].value).split(',') else: parameters[header] = col[0].value diff --git a/tass-converter/src/tass/converter/page_conf.py b/tass-converter/src/tass/converter/page_conf.py index b4c8f2a..f44cd51 100644 --- a/tass-converter/src/tass/converter/page_conf.py +++ b/tass-converter/src/tass/converter/page_conf.py @@ -19,6 +19,7 @@ class ElementType(StrEnum): CHECKSPECIFY = auto() DROPDOWN = auto() INTEGER = auto() + LEADINGZERO = "integerleadingzeros" TEXT = auto() PHONE = auto() EMAIL = auto() @@ -93,12 +94,14 @@ def parse_sheet(sheet, specs_out): radio_group = row[2].value case (ElementType.TEXT | ElementType.INTEGER | + ElementType.LEADINGZERO | ElementType.PHONE | ElementType.EMAIL | ElementType.CURRENCY | - ElementType.POSTALNOVAL | - ElementType.COMMENTBOX): + ElementType.POSTALNOVAL): ele.append([ElementType.TEXT, row[2].value]) + case ElementType.COMMENTBOX: + ele.append([ElementType.COMMENTBOX, row[2].value]) case ElementType.DROPDOWN: ele.append([ElementType.DROPDOWN, row[2].value]) case ElementType.CHECK | ElementType.CHECKSPECIFY: @@ -147,70 +150,125 @@ def convert_to_json(pages_path): page_number = 0 def parse_info(id, rostered): - if rostered: + if rostered == 1: return ( f'//input[contains(@name, ".Instance") and @value={{}}]' f'/following-sibling::*/descendant::div[contains(@id, "{id}")]' ) + elif rostered == 2: + return ( + f'//input[@id="__instance" and @value={{}}]' + f'/following-sibling::*/descendant::div[contains(@id, "{id}")]' + ) else: return f'//div[contains(@id, "{id}")]/ul/li[{{}}]' def parse_radio(id, val, rostered): - if rostered: + if rostered == 1: return ( f'//input[contains(@name, ".Instance") and @value={{}}]' '/following-sibling::*' f'/descendant::input[contains(@name, ".{id}")' f' and @value={val}]' ) + elif rostered == 2: + return ( + f'//input[@id="__instance" and @value={{}}]' + f'/following-sibling::*/descendant::input[contains(@name, "{id}")' + f' and @value="{val}"]' + ) else: return f'//input[contains(@name, ".{id}") and @value={val}]' def parse_radiotext(id, rostered): - if rostered: + if rostered == 1: return ( f'//input[contains(@name, ".Instance") and @value={{}}]' f'/following-sibling::*/descendant::input[@value="{id}"]' ) + elif rostered == 2: + return ( + f'//input[@id="__instance" and @value={{}}]' + f'/following-sibling::*/descendant::input[@value="{id}"]' + ) else: return f'//input[@value="{id}"]' def parse_check(id, rostered): - if rostered: + if rostered == 1: return ( f'//input[contains(@name, ".Instance") and @value={{}}]' '/following-sibling::*' f'/descendant::input[contains(@name, ".{id}")' ' and @type="checkbox"]' ) + elif rostered == 2: + return ( + f'//input[@id="__instance" and @value={{}}]' + f'/following-sibling::*/descendant::input[contains(@name, "{id}")' + f' and @type="checkbox"]' + ) else: return f'//input[@name="{id}" and @type="checkbox"]' def parse_dropdown(id, rostered): - if rostered: + if rostered == 1: return ( f'//input[contains(@name, ".Instance") and @value={{}}]' '/following-sibling::*' f'/descendant::select[contains(@name, ".{id}")]' ) + elif rostered == 2: + return ( + f'//input[@id="__instance" and @value={{}}]' + f'/following-sibling::*/descendant::select[contains(@name, "{id}")]' + ) else: return f'//select[@name="{id}"]' def parse_text(id, rostered): - if rostered: + if rostered == 1: return ( f'//input[contains(@name, ".Instance") and @value={{}}]' '/following-sibling::*' - f'/descendant::input[contains(@name, ".{id}")]' + f'/descendant::input[contains(@name, ".{id}")' + f' and not(@type="radio") and not(@type="checkbox")]' + ) + elif rostered == 2: + return ( + f'//input[@id="__instance" and @value={{}}]' + f'/following-sibling::*/descendant::input[contains(@name, "{id}")' + f' and not(@type="radio") and not(@type="checkbox")]' ) else: return f'//input[@name="{id}"]' + + def parse_comment(id, rostered): + if rostered == 1: + return ( + f'//textarea[contains(@name, ".Instance") and @value={{}}]' + '/following-sibling::*' + f'/descendant::input[contains(@name, ".{id}")' + f' and not(@type="radio") and not(@type="checkbox")]' + ) + elif rostered == 2: + return ( + f'//textarea[@id="__instance" and @value={{}}]' + f'/following-sibling::*/descendant::input[contains(@name, "{id}")' + f' and not(@type="radio") and not(@type="checkbox")]' + ) + else: + return f'//textarea[@name="{id}"]' for count, row in enumerate(ws.iter_rows(min_row=2, max_col=6), 2): print("This is the row:", row) row_type = row[0].value element_id = row[1].value - rostered = row[2].value and row[2].value == 1 + + if (row[2].value and (row[2].value == 1 or row[2].value == 2)): + rostered = row[2].value + else: + rostered = 0 if row_type == Element.BREAK: print("Page Number:", page_number) if not page and not elements: @@ -276,6 +334,11 @@ def parse_text(id, rostered): "by": "xpath", "value": parse_text(element_id, rostered) } + elif row_type == ElementType.COMMENTBOX: + elements[element_id] = { + "by": "xpath", + "value": parse_comment(element_id, rostered) + } elif row_type == ElementType.DROPDOWN: elements[element_id] = { "by": "xpath",