Skip to content

Commit 0013985

Browse files
authored
Merge pull request #7 from qahive/enhance-support-new-line-data-column
Add support field with newline by replace with under score
2 parents f05d19c + 6d4b177 commit 0013985

File tree

6 files changed

+17
-21
lines changed

6 files changed

+17
-21
lines changed

Examples/BasicDataDrivenExample.robot

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
Library ExcelDataDriver ./test_data/BasicDemoData.xlsx capture_screenshot=Skip main_column_key=username
33
Test Template Validate user data template
44

5+
*** Variables ***
6+
${username} ${EMPTY}
7+
58
*** Test Cases ***
6-
Verify valid user '${username}' ${None} ${None} ${None}
9+
Verify valid user '${username}' ${None} ${None} ${None} ${None}
710

811
*** Keywords ***
912
Validate user data template
10-
[Arguments] ${username} ${password} ${email}
13+
[Arguments] ${username} ${password} ${email} ${data_new_line}
1114
Log ${username}
1215
Log ${password}
1316
Log ${email}
17+
Log ${data_new_line}
18+
Should Not Be Equal ${data_new_line} ${None}
1419
Should Not Be Equal ${password} ${None}

Examples/CustomParserExample.robot

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Library CustomExcelParser/CustomExcelParser.py
33
Library ExcelDataDriver ./test_data/Custom_Template.xlsx main_column_key=sku custom_parser=CustomExcelParser capture_screenshot=OnFailed
44
Test Template Demo template
55

6+
*** Variables ***
7+
${sku} ${EMPTY}
68

79
*** Test Cases ***
810
Product promo price update for SKU '${sku}' ${None} ${None} ${None} ${None} ${None} ${None} ${None} ${None} ${None}

Examples/SeleniumDataDrivenExample.robot

Lines changed: 0 additions & 17 deletions
This file was deleted.
3.75 KB
Binary file not shown.
212 Bytes
Binary file not shown.

ExcelDataDriver/ExcelParser/ABCParserStrategy.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def parsing_major_column_indexs(self, ws):
5454
found_default_column_indexs = True
5555

5656
if (cell.value is not None) and (cell.value not in self.DEFAULT_COLUMN_INDEXS) and (found_default_column_indexs is False):
57-
field_name = str(cell.value).lower().strip().replace(" ", "_")
57+
field_name = self._cleanup_fieldname(cell.value)
5858
if field_name == self.main_column_key:
5959
key_index_row = index + 1
6060

@@ -87,7 +87,7 @@ def parsing_column_indexs(self, ws):
8787
continue
8888
for cell in row:
8989
if (cell.value is not None) and (cell.value not in self.DEFAULT_COLUMN_INDEXS):
90-
field_name = str(cell.value).lower().strip().replace(" ", "_")
90+
field_name = self._cleanup_fieldname(cell.value)
9191
ws_column_indexs[field_name] = column_index_from_string(coordinate_from_string(cell.coordinate)[0])
9292
print(str(datetime.now())+': Optional : '+field_name + ' : ' + str(cell.coordinate) + ' : ' + str(column_index_from_string(coordinate_from_string(cell.coordinate)[0])))
9393
break
@@ -107,3 +107,9 @@ def parse_test_data_properties(self, ws, ws_column_indexs):
107107
print(str(datetime.now())+': Total test datas: ' + str(len(test_datas)))
108108
return test_datas
109109

110+
def _cleanup_fieldname(self, field_name):
111+
field_name = str(field_name).lower().strip().replace(" ", "_")
112+
field_name = field_name.replace("\r", "_")
113+
field_name = field_name.replace("\n", "_")
114+
field_name = field_name.replace("__", "_")
115+
return field_name

0 commit comments

Comments
 (0)