diff --git a/Framework/Built_In_Automation/Desktop/Windows/BuiltInFunctions.py b/Framework/Built_In_Automation/Desktop/Windows/BuiltInFunctions.py index d30516466..7cf2ea258 100644 --- a/Framework/Built_In_Automation/Desktop/Windows/BuiltInFunctions.py +++ b/Framework/Built_In_Automation/Desktop/Windows/BuiltInFunctions.py @@ -2341,16 +2341,15 @@ def save_attribute_values_in_list(data_set): right = right.strip() if "target parameter" in mid: target.append([[], "", [], []]) - temp = right.strip(",").split('",\n') + temp = right.strip(",").split(',\n') data = [] - temp[-1] = temp[-1][:-1] for each in temp: data.append(each.strip().split("=", 1)) for i in range(len(data)): for j in range(len(data[i])): data[i][j] = data[i][j].strip() if j == 1: - data[i][j] = data[i][j][1:] # dont add another strip here. dont need to strip inside quotation mark + data[i][j] = CommonUtil.strip1(data[i][j], '"') # dont add another strip here. dont need to strip inside quotation mark for Left, Right in data: if Left == "return": diff --git a/Framework/Built_In_Automation/Mobile/CrossPlatform/Appium/BuiltInFunctions.py b/Framework/Built_In_Automation/Mobile/CrossPlatform/Appium/BuiltInFunctions.py index 00a9009ff..74a3442fe 100755 --- a/Framework/Built_In_Automation/Mobile/CrossPlatform/Appium/BuiltInFunctions.py +++ b/Framework/Built_In_Automation/Mobile/CrossPlatform/Appium/BuiltInFunctions.py @@ -4062,16 +4062,15 @@ def save_attribute_values_appium(step_data): right = right.strip() if "target parameter" in mid: target.append([[], [], [], []]) - temp = right.strip(",").split('",\n') + temp = right.strip(",").split(',\n') data = [] - temp[-1] = temp[-1][:-1] for each in temp: - data.append(each.strip().split("=",1)) + data.append(each.strip().split("=", 1)) for i in range(len(data)): for j in range(len(data[i])): data[i][j] = data[i][j].strip() if j == 1: - data[i][j] = data[i][j][1:] # do not add another strip here. dont need to strip inside quotation mark + data[i][j] = CommonUtil.strip1(data[i][j], '"') # do not add another strip here. dont need to strip inside quotation mark for Left, Right in data: if Left == "return": diff --git a/Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py b/Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py index 8b6d96b1b..0fa4c6eb8 100644 --- a/Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py +++ b/Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py @@ -2730,16 +2730,15 @@ def save_attribute_values_in_list(step_data): right = right.strip() if "target parameter" in mid: target.append([[], [], [], []]) - temp = right.strip(",").split('",\n') + temp = right.strip(",").split(',\n') data = [] - temp[-1] = temp[-1][:-1] for each in temp: - data.append(each.strip().split("=",1)) + data.append(each.strip().split("=", 1)) for i in range(len(data)): for j in range(len(data[i])): data[i][j] = data[i][j].strip() if j == 1: - data[i][j] = data[i][j][1:] # dont add another strip here. dont need to strip inside quotation mark + data[i][j] = CommonUtil.strip1(data[i][j], '"') # dont add another strip here. dont need to strip inside quotation mark for Left, Right in data: if Left == "return": @@ -3156,83 +3155,37 @@ def Sleep(step_data): def Scroll(step_data): sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME global selenium_driver - selenium_driver.switch_to.default_content() try: - scroll_inside_element = False - scroll_window_name = "window" - scroll_window = "" - action_row = None - - for row in step_data: - if str(row[1]) == "action": - action_row = row - break - - if not action_row: - CommonUtil.ExecLog(sModuleInfo, "No action row defined", 3) - return "zeuz_failed" - - if ( - len(step_data) > 1 - ): # element given scroll inside element, not on full window - scroll_inside_element = True - scroll_window_name = "arguments[0]" - - if scroll_inside_element: - scroll_window = LocateElement.Get_Element(step_data, selenium_driver) - if scroll_window in failed_tag_list: - CommonUtil.ExecLog( - sModuleInfo, - "Element through which instructed to scroll not found", - 3, - ) - return "zeuz_failed" + Element = None + get_element = False + scroll_direction = "" + offset = "" + pixel = 750 + for left, mid, right in step_data: + mid = mid.strip().lower() + if "action" in mid: + scroll_direction = right.strip().lower() + elif mid == "element parameter": + get_element = True + elif left.strip().lower() == "pixels": + pixel = int(right.strip().lower()) - CommonUtil.ExecLog( - sModuleInfo, - "Element inside which instructed to scroll has been found. Scrolling thorugh it", - 1, - ) - else: - CommonUtil.ExecLog(sModuleInfo, "Scrolling through main window", 1) + if get_element: + Element = LocateElement.Get_Element(step_data, selenium_driver) - scroll_direction = str(action_row[2]).strip().lower() if scroll_direction == "down": - CommonUtil.ExecLog(sModuleInfo, "Scrolling down", 1) - result = selenium_driver.execute_script( - "%s.scrollBy(0,750)" % scroll_window_name, scroll_window - ) - time.sleep(2) - return "passed" + offset = f"0,{pixel}" elif scroll_direction == "up": - CommonUtil.ExecLog(sModuleInfo, "Scrolling up", 1) - result = selenium_driver.execute_script( - "%s.scrollBy(0,-750)" % scroll_window_name, scroll_window - ) - time.sleep(2) - return "passed" + offset = f"0,-{pixel}" elif scroll_direction == "left": - CommonUtil.ExecLog(sModuleInfo, "Scrolling left", 1) - result = selenium_driver.execute_script( - "%s.scrollBy(-750,0)" % scroll_window_name, scroll_window - ) - time.sleep(2) - return "passed" + offset = f"-{pixel},0" elif scroll_direction == "right": - CommonUtil.ExecLog(sModuleInfo, "Scrolling right", 1) - result = selenium_driver.execute_script( - "%s.scrollBy(750,0)" % scroll_window_name, scroll_window - ) - time.sleep(2) - return "passed" - else: - CommonUtil.ExecLog( - sModuleInfo, - "Value invalid. Only 'up', 'down', 'right' and 'left' allowed", - 3, - ) - result = "zeuz_failed" - return result + offset = f"{pixel},0" + + CommonUtil.ExecLog(sModuleInfo, f"Scrolling {scroll_direction}", 1) + selenium_driver.execute_script(f"{'arguments[0]' if Element is not None else 'window'}.scrollBy({offset})") + time.sleep(2) + return "passed" except Exception: return CommonUtil.Exception_Handler(sys.exc_info()) diff --git a/Framework/Utilities/CommonUtil.py b/Framework/Utilities/CommonUtil.py index aedd28b5c..1cfac7f74 100644 --- a/Framework/Utilities/CommonUtil.py +++ b/Framework/Utilities/CommonUtil.py @@ -344,6 +344,14 @@ def Add_File_To_Current_Test_Case_Log(src): return Exception_Handler(sys.exc_info()) +def strip1(original_value: str, remove: str) -> str: + if original_value.startswith(remove): + original_value = original_value[len(remove):] + if original_value.endswith(remove): + original_value = original_value[:-len(remove)] + return original_value + + def Exception_Handler(exec_info, temp_q=None, UserMessage=None): try: # console.print_exception(show_locals=True, max_frames=1)