4646from Framework .Utilities .CommonUtil import passed_tag_list , failed_tag_list
4747from . import locator as PlaywrightLocator
4848
49+ def _get_frame_locator ():
50+ """Helper function to get current frame locator from shared variables."""
51+ frame_locator = sr .Get_Shared_Variables ("playwright_frame" )
52+ if frame_locator in failed_tag_list :
53+ return None
54+ return frame_locator
55+
4956#########################
5057# #
5158# Global Variables #
@@ -495,7 +502,7 @@ async def Click_Element(step_data):
495502 right_click = True
496503
497504 # Get element
498- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
505+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
499506 if locator == "zeuz_failed" :
500507 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
501508 return "zeuz_failed"
@@ -609,7 +616,7 @@ async def Hover_Over_Element(step_data):
609616 elif left_l == "timeout" :
610617 timeout = int (float (right_v ) * 1000 )
611618
612- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
619+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
613620 if locator == "zeuz_failed" :
614621 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
615622 return "zeuz_failed"
@@ -686,7 +693,7 @@ async def Enter_Text_In_Text_Box(step_data):
686693 elif left_l == "timeout" :
687694 timeout = int (float (right .strip ()) * 1000 )
688695
689- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
696+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
690697 if locator == "zeuz_failed" :
691698 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
692699 return "zeuz_failed"
@@ -830,7 +837,7 @@ async def Keystroke_For_Element(step_data):
830837 key = key_map .get (key , keystroke_value )
831838
832839 if has_element :
833- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
840+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
834841 if locator == "zeuz_failed" :
835842 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
836843 return "zeuz_failed"
@@ -853,7 +860,7 @@ async def Keystroke_For_Element(step_data):
853860 type_options ["delay" ] = int (delay * 1000 )
854861
855862 if has_element :
856- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
863+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
857864 if locator == "zeuz_failed" :
858865 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
859866 return "zeuz_failed"
@@ -930,7 +937,7 @@ async def Validate_Text(step_data):
930937 if left_l == "timeout" :
931938 timeout = int (float (right_v ) * 1000 )
932939
933- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
940+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
934941 if locator == "zeuz_failed" :
935942 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
936943 return "zeuz_failed"
@@ -995,7 +1002,7 @@ async def if_element_exists(step_data):
9951002 if mid_l == "optional parameter" and left_l == "timeout" :
9961003 timeout = int (float (right_v ) * 1000 )
9971004
998- locator = await PlaywrightLocator .Get_Element (step_data , current_page , element_wait = timeout / 1000 )
1005+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , element_wait = timeout / 1000 , frame_locator = _get_frame_locator () )
9991006
10001007 if locator == "zeuz_failed" :
10011008 CommonUtil .ExecLog (sModuleInfo , "Element does not exist" , 1 )
@@ -1069,7 +1076,7 @@ async def Save_Attribute(step_data):
10691076 CommonUtil .ExecLog (sModuleInfo , "No save variable specified" , 3 )
10701077 return "zeuz_failed"
10711078
1072- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
1079+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
10731080 if locator == "zeuz_failed" :
10741081 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
10751082 return "zeuz_failed"
@@ -1131,7 +1138,7 @@ async def get_element_info(step_data):
11311138 if mid .strip ().lower () == "save parameter" :
11321139 save_variable = left .strip ()
11331140
1134- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
1141+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
11351142 if locator == "zeuz_failed" :
11361143 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
11371144 return "zeuz_failed"
@@ -1363,7 +1370,7 @@ async def scroll_to_element(step_data):
13631370 elif left_l == "align to top" :
13641371 align_to_top = right_v .lower () in ("true" , "yes" , "1" )
13651372
1366- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
1373+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
13671374 if locator == "zeuz_failed" :
13681375 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
13691376 return "zeuz_failed"
@@ -1443,7 +1450,7 @@ async def Select_Deselect(step_data):
14431450 CommonUtil .ExecLog (sModuleInfo , "No selection value provided" , 3 )
14441451 return "zeuz_failed"
14451452
1446- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
1453+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
14471454 if locator == "zeuz_failed" :
14481455 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
14491456 return "zeuz_failed"
@@ -1521,7 +1528,7 @@ async def check_uncheck(step_data):
15211528 if left_l == "use js" :
15221529 use_js = right_v in ("true" , "yes" , "1" )
15231530
1524- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
1531+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
15251532 if locator == "zeuz_failed" :
15261533 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
15271534 return "zeuz_failed"
@@ -1758,7 +1765,7 @@ def close_tab(step_data):
17581765#########################
17591766
17601767@logger
1761- def switch_iframe (step_data ):
1768+ async def switch_iframe (step_data ):
17621769 """
17631770 Switch to an iframe or back to main content.
17641771
@@ -1806,6 +1813,7 @@ def switch_iframe(step_data):
18061813 if switch_to_default :
18071814 # In Playwright, we work with the main page directly
18081815 # Store a flag or reset frame locator
1816+ sr .Set_Shared_Variables ("playwright_frame" , None )
18091817 CommonUtil .ExecLog (sModuleInfo , "Switched to default content" , 1 )
18101818 return "passed"
18111819
@@ -1974,13 +1982,13 @@ async def drag_and_drop(step_data):
19741982 source_param = left .strip ()
19751983
19761984 # Get source element
1977- source_locator = await PlaywrightLocator .Get_Element (source_param , current_page )
1985+ source_locator = await PlaywrightLocator .Get_Element (source_param , current_page , frame_locator = _get_frame_locator () )
19781986 if source_locator == "zeuz_failed" :
19791987 CommonUtil .ExecLog (sModuleInfo , "Source element not found" , 3 )
19801988 return "zeuz_failed"
19811989
19821990 # Get target element
1983- target_locator = await PlaywrightLocator .Get_Element (target_param , current_page )
1991+ target_locator = await PlaywrightLocator .Get_Element (target_param , current_page , frame_locator = _get_frame_locator () )
19841992 if target_locator == "zeuz_failed" :
19851993 CommonUtil .ExecLog (sModuleInfo , "Target element not found" , 3 )
19861994 return "zeuz_failed"
@@ -2053,7 +2061,7 @@ async def take_screenshot_playwright(step_data):
20532061
20542062 # Take screenshot
20552063 if has_element :
2056- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
2064+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
20572065 if locator == "zeuz_failed" :
20582066 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
20592067 return "zeuz_failed"
@@ -2123,7 +2131,7 @@ async def execute_javascript(step_data):
21232131
21242132 # Execute JS
21252133 if has_element :
2126- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
2134+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
21272135 if locator == "zeuz_failed" :
21282136 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
21292137 return "zeuz_failed"
@@ -2193,7 +2201,7 @@ async def upload_file(step_data):
21932201 CommonUtil .ExecLog (sModuleInfo , f"File not found: { file_path } " , 3 )
21942202 return "zeuz_failed"
21952203
2196- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
2204+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
21972205 if locator == "zeuz_failed" :
21982206 CommonUtil .ExecLog (sModuleInfo , "Element not found" , 3 )
21992207 return "zeuz_failed"
@@ -2320,7 +2328,7 @@ async def Wait_For_Element(step_data):
23202328 if timeout :
23212329 await asyncio .sleep (timeout )
23222330
2323- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
2331+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
23242332
23252333 if locator == "zeuz_failed" :
23262334 # For hidden/detached states, element not found is actually success
@@ -2539,7 +2547,7 @@ async def Extract_Table_Data(step_data):
25392547 elif left_l == "column" :
25402548 col_filter = right_v
25412549
2542- locator = await PlaywrightLocator .Get_Element (step_data , current_page )
2550+ locator = await PlaywrightLocator .Get_Element (step_data , current_page , frame_locator = _get_frame_locator () )
25432551 if locator == "zeuz_failed" :
25442552 CommonUtil .ExecLog (sModuleInfo , "Table element not found" , 3 )
25452553 return "zeuz_failed"
0 commit comments