Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
101 changes: 27 additions & 74 deletions Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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())
Expand Down
8 changes: 8 additions & 0 deletions Framework/Utilities/CommonUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down