Skip to content

Commit c133317

Browse files
authored
Merge pull request #173 from AutomationSolutionz/dev
Release 15.0.4
2 parents e8eba82 + b92bad4 commit c133317

File tree

15 files changed

+1159
-91
lines changed

15 files changed

+1159
-91
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
# Changelog
22

3-
# Version 14
3+
# Version 15
44

55
### [Current changes]
66
- _
77

8+
### [15.0.4][May 11, 2022]
9+
- **[Improve]** Added plus button support in keystroke action
10+
11+
### [15.0.3][May 08, 2022]
12+
- **[Change]** Removed printing the whole traceback of error
13+
14+
### [15.0.2][April 26, 2022]
15+
- **[Add]** `%|zeuz_auto_teardown|%` variable is added for turning off auto teardown
16+
17+
### [15.0.1][April 26, 2022]
18+
- **[Change]** Screenshot image quality upgraded to resolution 1920,1080
19+
820
### [15.0.0][April 16, 2022]
921
- **[Add]** Added capability for handling alert as desired.
1022
- **[Add]** Added action read scanned pdf
@@ -23,6 +35,8 @@
2335
- **[Fix]** import pyautogui fix for ui-less machine
2436
- **[Remove]** SSL validation is bypassed while installing webdriver
2537

38+
# Version 14
39+
2640
### [14.11.2][March 30, 2022]
2741
- **[Fix]** Pyautogui import fix for ui-less machine
2842
- **[Add]** Added missing commits of `Alert` and `Android browser`

Framework/Built_In_Automation/Desktop/Windows/BuiltInFunctions.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,7 +1743,7 @@ def Keystroke_For_Element(data_set):
17431743
left = left.strip().lower()
17441744
if "action" in mid.lower():
17451745
if left == "keystroke keys":
1746-
keystroke_value = right.lower() # Store keystroke
1746+
keystroke_value = right.strip().lower() # Store keystroke
17471747
elif left == "keystroke chars":
17481748
keystroke_char = right
17491749
if "parameter"in mid.lower():
@@ -1776,14 +1776,21 @@ def Keystroke_For_Element(data_set):
17761776
keystroke_value, count = keystroke_value.split(",")
17771777
count = int(count.strip())
17781778
keys = keystroke_value.split("+")
1779-
keys = [x.strip() for x in keys]
1779+
for i in range(len(keys)):
1780+
keys[i] = keys[i].strip()
1781+
if keys[i] == "plus":
1782+
keys[i] = "+"
1783+
elif keys[i] == "minus":
1784+
keys[i] = "-"
1785+
elif keys[i] == "comma":
1786+
keys[i] = ","
17801787

17811788
for i in range(count):
17821789
gui.hotkey(*keys) # Send keypress (as individual values using the asterisk)
17831790
CommonUtil.ExecLog(sModuleInfo, "Successfully entered keystroke", 1)
17841791
return "passed"
17851792

1786-
elif method_name=='autoit':
1793+
elif method_name == 'autoit':
17871794
try:
17881795
if keystroke_char != "":
17891796
autoit.send(keystroke_char)
@@ -1794,26 +1801,31 @@ def Keystroke_For_Element(data_set):
17941801
return CommonUtil.Exception_Handler(sys.exc_info(), None, errMsg)
17951802

17961803
count = 1
1797-
keystroke_value = keystroke_value
17981804
if "," in keystroke_value:
17991805
keystroke_value, count = keystroke_value.split(",")
18001806
count = int(count.strip())
18011807
keys = keystroke_value.split("+")
1802-
keys = [x.strip() for x in keys]
1808+
for i in range(len(keys)):
1809+
keys[i] = keys[i].strip()
1810+
if keys[i] == "plus":
1811+
keys[i] = "+"
1812+
elif keys[i] == "minus":
1813+
keys[i] = "-"
1814+
elif keys[i] == "comma":
1815+
keys[i] = ","
18031816

18041817
send_key = ""
18051818
for i in range(len(keys)):
18061819
if i == len(keys)-1:
18071820
send_key += '{' + keys[i] + ' ' + str(count) + '}'
18081821
else:
1809-
upper = keys[i].upper()
1810-
if upper == 'SHIFT':
1822+
if keys[i] == 'shift':
18111823
send_key += '+'
1812-
elif upper == 'CTRL':
1824+
elif keys[i] == 'ctrl':
18131825
send_key += '^'
1814-
elif upper == 'ALT':
1826+
elif keys[i] == 'alt':
18151827
send_key += '!'
1816-
elif upper == 'WIN':
1828+
elif keys[i] == 'win':
18171829
send_key += '#'
18181830
# print(send_key)
18191831
autoit.send(send_key)

Framework/Built_In_Automation/Sequential_Actions/action_declarations/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"attribute constrain",
7676
"optional option",
7777
"graphql",
78-
"capability"
78+
"shared capability"
7979
)
8080

8181
# List of supported mobile platforms - must be lower case

Framework/Built_In_Automation/Sequential_Actions/common_functions.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4464,24 +4464,22 @@ def download_attachment_from_global(data_set):
44644464
"""
44654465
usage: This action allows you to download attachments from a testcase id
44664466
dataset :
4467-
attachment name | input parameter | name
44684467
path to save | optional parameter | path
4469-
download attachment from global | common action | result
4468+
download attachment from global | common action | attachment name
44704469
44714470
return : return True/False
44724471
note: attachment name will be the name of that attachment ,result will be the variable name to store
44734472
"""
44744473
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
44754474
try:
44764475
var_name = None
4477-
var_path = None
4476+
var_path = sr.Get_Shared_Variables("zeuz_download_folder")
44784477
for left, mid, right in data_set:
44794478
left = left.strip().lower()
4480-
if "attachment name" == left:
4481-
var_name = right.strip()
44824479
if "path to save" == left:
44834480
var_path = CommonUtil.path_parser(right)
4484-
4481+
if "download attachment from global"==left:
4482+
var_name=right.strip()
44854483
if var_path is None:
44864484
CommonUtil.ExecLog(sModuleInfo, "Please insert attachment path to download ", 3)
44874485
return "zeuz_failed"

Framework/Built_In_Automation/Shared_Resources/LocateElement.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@ def Get_Element(step_data_set, driver, query_debug=False, return_all_elements=Fa
220220
if save_parameter != "": # save element to a variable
221221
sr.Set_Shared_Variables(save_parameter, result)
222222
return result # Return on pass
223+
elif result == "zeuz_failed":
224+
try:
225+
if len(generic_driver.find_elements(By.TAG_NAME, "iframe")) > 0:
226+
CommonUtil.ExecLog(sModuleInfo, "You have Iframes in your Webpage. Try switching Iframe with \"Switch Iframe\" action", 3)
227+
elif len(generic_driver.find_elements(By.TAG_NAME, "frame")) > 0:
228+
CommonUtil.ExecLog(sModuleInfo, "You have Frames in your Webpage. Try switching Frame with \"Switch Iframe\" action", 3)
229+
except:
230+
pass
223231
return "zeuz_failed"
224232
except Exception:
225233
return CommonUtil.Exception_Handler(sys.exc_info())
@@ -786,12 +794,12 @@ def _get_xpath_or_css_element(element_query, css_xpath,data_set, index_number=No
786794

787795
if all_matching_elements_visible_invisible and len(filter_elements(all_matching_elements_visible_invisible, "")) > 0:
788796
break
789-
elif time.time() > end:
797+
if time.time() > end:
790798
break
791799
# end of while loop
792800

793801
if exception_cnd:
794-
return False
802+
return "zeuz_failed"
795803

796804
if driver_type == "appium" and index_number is not None and index_number > 0 and len(all_matching_elements_visible_invisible) == 0:
797805
CommonUtil.ExecLog(sModuleInfo, "Element not found and we do not support Auto Scroll when index is provided", 2)
@@ -830,7 +838,7 @@ def _get_xpath_or_css_element(element_query, css_xpath,data_set, index_number=No
830838
"To get hidden elements add a row (\"allow hidden\", \"optional option\", \"yes\")",
831839
3
832840
)
833-
return False
841+
return "zeuz_failed"
834842
elif len(all_matching_elements) == 1 and index_number is None:
835843
if hidden_len > 0 and Filter != "allow hidden":
836844
CommonUtil.ExecLog(

Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,14 +777,18 @@ def Go_To_Link(step_data, page_title=False):
777777
driver_id = right.strip()
778778

779779
# checks for capabilities and modifies them by the given step_data
780-
elif mid.strip().lower() == "capability":
780+
elif mid.strip().lower() == "shared capability":
781781
if left.strip().lower() in ("promptbehavior", "alertbehavior"):
782782
if right.strip().lower() in ("accept", "yes", "ok"):
783783
capabilities["unhandledPromptBehavior"] = "accept"
784784

785785
elif right.strip().lower() in ("dismiss", "no", "cancel"):
786786
capabilities["unhandledPromptBehavior"] = "dismiss"
787787

788+
else:
789+
# any other shared capabilities can be added from the selenium document
790+
capabilities[left.strip()] = right.strip()
791+
788792
if not driver_id:
789793
driver_id = "default"
790794

Framework/MainDriverApi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,8 @@ def run_test_case(
898898

899899
if not CommonUtil.debug_status: # if normal run, then write log file and cleanup driver instances
900900
CommonUtil.Join_Thread_and_Return_Result("screenshot") # Let the capturing screenshot end in thread
901-
cleanup_driver_instances() # clean up drivers
901+
if shared.Get_Shared_Variables("zeuz_auto_teardown").strip().lower() in ("on", "yes", "true", "ok", "enable"):
902+
cleanup_driver_instances() # clean up drivers
902903
shared.Clean_Up_Shared_Variables() # clean up shared variables
903904
if ConfigModule.get_config_value("RunDefinition", "local_run") == "False":
904905

@@ -1419,6 +1420,7 @@ def main(device_dict, user_info_object):
14191420
rerun_on_fail = ConfigModule.get_config_value("RunDefinition", "rerun_on_fail")
14201421
rerun_on_fail = False if rerun_on_fail.lower() == "false" else True
14211422
CommonUtil.upload_on_fail, CommonUtil.rerun_on_fail = send_log_file_only_for_fail, rerun_on_fail
1423+
shared.Set_Shared_Variables("zeuz_auto_teardown", "on")
14221424

14231425
all_testcases_info = run_id_info["test_cases"]
14241426
TestSetStartTime = time.time()

Framework/Utilities/CommonUtil.py

Lines changed: 52 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -264,55 +264,55 @@ def Add_File_To_Current_Test_Case_Log(src):
264264

265265
def Exception_Handler(exec_info, temp_q=None, UserMessage=None):
266266
try:
267-
console.print_exception(show_locals=True, max_frames=1)
268-
# sModuleInfo_Local = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
269-
# exc_type, exc_obj, exc_tb = exec_info
270-
# Error_Type = (
271-
# (str(exc_type).replace("type ", ""))
272-
# .replace("<", "")
273-
# .replace(">", "")
274-
# .replace(";", ":")
275-
# )
276-
# Error_Message = str(exc_obj)
277-
# File_Name = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
278-
# Function_Name = os.path.split(exc_tb.tb_frame.f_code.co_name)[1]
279-
# Line_Number = str(exc_tb.tb_lineno)
280-
# Error_Detail = (
281-
# "Error Type ~ %s: Error Message ~ %s: File Name ~ %s: Function Name ~ %s: Line ~ %s"
282-
# % (Error_Type, Error_Message, File_Name, Function_Name, Line_Number)
283-
# )
284-
# sModuleInfo = Function_Name + ":" + File_Name
285-
# ExecLog(sModuleInfo, "Following exception occurred: %s" % (Error_Detail), 3)
286-
# # TakeScreenShot(Function_Name + "~" + File_Name)
287-
# if UserMessage != None:
288-
# ExecLog(
289-
# sModuleInfo, "Following error message is custom: %s" % (UserMessage), 3
290-
# )
291-
if temp_q != None:
292-
temp_q.put("zeuz_failed")
267+
# console.print_exception(show_locals=True, max_frames=1)
268+
sModuleInfo_Local = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
269+
exc_type, exc_obj, exc_tb = exec_info
270+
Error_Type = (
271+
(str(exc_type).replace("type ", ""))
272+
.replace("<", "")
273+
.replace(">", "")
274+
.replace(";", ":")
275+
)
276+
Error_Message = str(exc_obj)
277+
File_Name = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
278+
Function_Name = os.path.split(exc_tb.tb_frame.f_code.co_name)[1]
279+
Line_Number = str(exc_tb.tb_lineno)
280+
Error_Detail = (
281+
"Error Type ~ %s: Error Message ~ %s: File Name ~ %s: Function Name ~ %s: Line ~ %s"
282+
% (Error_Type, Error_Message, File_Name, Function_Name, Line_Number)
283+
)
284+
sModuleInfo = Function_Name + ":" + File_Name
285+
ExecLog(sModuleInfo, "Following exception occurred: %s" % (Error_Detail), 3)
286+
# TakeScreenShot(Function_Name + "~" + File_Name)
287+
if UserMessage != None:
288+
ExecLog(
289+
sModuleInfo, "Following error message is custom: %s" % (UserMessage), 3
290+
)
291+
# if temp_q != None:
292+
# temp_q.put("zeuz_failed")
293293

294294
return "zeuz_failed"
295295

296296
except Exception:
297-
# exc_type_local, exc_obj_local, exc_tb_local = sys.exc_info()
298-
# fname_local = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
299-
# Error_Detail_Local = (
300-
# (str(exc_type_local).replace("type ", "Error Type: "))
301-
# + ";"
302-
# + "Error Message: "
303-
# + str(exc_obj_local)
304-
# + ";"
305-
# + "File Name: "
306-
# + fname_local
307-
# + ";"
308-
# + "Line: "
309-
# + str(exc_tb_local.tb_lineno)
310-
# )
311-
# ExecLog(
312-
# sModuleInfo_Local,
313-
# "Following exception occurred: %s" % (Error_Detail_Local),
314-
# 3,
315-
# )
297+
exc_type_local, exc_obj_local, exc_tb_local = sys.exc_info()
298+
fname_local = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
299+
Error_Detail_Local = (
300+
(str(exc_type_local).replace("type ", "Error Type: "))
301+
+ ";"
302+
+ "Error Message: "
303+
+ str(exc_obj_local)
304+
+ ";"
305+
+ "File Name: "
306+
+ fname_local
307+
+ ";"
308+
+ "Line: "
309+
+ str(exc_tb_local.tb_lineno)
310+
)
311+
ExecLog(
312+
sModuleInfo_Local,
313+
"Following exception occurred: %s" % (Error_Detail_Local),
314+
3,
315+
)
316316
return "zeuz_failed"
317317

318318

@@ -753,8 +753,8 @@ def Thread_ScreenShot(function_name, image_folder, Method, Driver, image_name):
753753
r"\/",
754754
r":",
755755
] # Symbols that can't be used in filename
756-
picture_quality = 20 # Quality of picture
757-
picture_size = 800, 600 # Size of image (for reduction in file size)
756+
picture_quality = 100 # Quality of picture
757+
picture_size = 1920, 1080 # Size of image (for reduction in file size)
758758

759759
# Adjust filename and create full path (remove invalid characters, convert spaces to underscore, remove leading and trailing spaces)
760760
trans_table = str.maketrans(
@@ -773,9 +773,7 @@ def Thread_ScreenShot(function_name, image_folder, Method, Driver, image_name):
773773
image.save(ImageName, format="PNG") # Save to disk
774774

775775
# Exit if we don't have a driver yet (happens when Test Step is set to mobile/web, but we haven't setup the driver)
776-
elif Driver == None and (
777-
Method == "mobile" or Method == "web"
778-
):
776+
elif Driver is None and Method in ("mobile", "web"):
779777
ExecLog(
780778
sModuleInfo,
781779
"Can't capture screen, driver not available for type: %s, or invalid driver: %s"
@@ -786,15 +784,11 @@ def Thread_ScreenShot(function_name, image_folder, Method, Driver, image_name):
786784

787785
# Capture screenshot of web browser
788786
elif Method == "web":
789-
Driver.get_screenshot_as_file(
790-
ImageName
791-
) # Must be .png, otherwise an exception occurs
787+
Driver.get_screenshot_as_file(ImageName) # Must be .png, otherwise an exception occurs
792788

793789
# Capture screenshot of mobile
794790
elif Method == "mobile":
795-
Driver.save_screenshot(
796-
ImageName
797-
) # Must be .png, otherwise an exception occurs
791+
Driver.save_screenshot(ImageName) # Must be .png, otherwise an exception occurs
798792
else:
799793
ExecLog(
800794
sModuleInfo,
@@ -805,12 +799,8 @@ def Thread_ScreenShot(function_name, image_folder, Method, Driver, image_name):
805799
# Lower the picture quality
806800
if os.path.exists(ImageName): # Make sure image was saved
807801
image = Image.open(ImageName) # Re-open in standard format
808-
image.thumbnail(
809-
picture_size, Image.ANTIALIAS
810-
) # Resize picture to lower file size
811-
image.save(
812-
ImageName, format="PNG", quality=picture_quality
813-
) # Change quality to reduce file size
802+
image.thumbnail(picture_size, Image.ANTIALIAS) # Resize picture to lower file size
803+
image.save(ImageName, format="PNG", quality=picture_quality) # Change quality to reduce file size
814804

815805
# Convert image to bytearray and send it to ws for streaming.
816806
image_byte_array = pil_image_to_bytearray(image)

Framework/Version.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[ZeuZ Python Version]
2-
version = 15.0.0
2+
version = 15.0.4
33
[Release Date]
4-
date = April 16, 2022
4+
date = May 11, 2022

0 commit comments

Comments
 (0)