Skip to content

Commit 1f0e02d

Browse files
committed
Fix drag and drop not passing correct step data to element locator
1 parent 289ebf9 commit 1f0e02d

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

Framework/Built_In_Automation/Web/Playwright/BuiltInFunctions.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,14 @@
4848

4949
def _get_frame_locator():
5050
"""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:
51+
try:
52+
frame_locator = sr.Get_Shared_Variables("playwright_frame")
53+
if frame_locator in failed_tag_list:
54+
return None
55+
return frame_locator
56+
except:
57+
# Variable doesn't exist yet
5358
return None
54-
return frame_locator
5559

5660
#########################
5761
# #
@@ -1977,18 +1981,18 @@ async def drag_and_drop(step_data):
19771981
mid_l = mid.strip().lower()
19781982
if "element parameter" in mid_l:
19791983
if mid_l.startswith("dst"):
1980-
target_param = left.strip()
1984+
target_param = (left, mid, right)
19811985
elif mid_l.startswith("src"):
1982-
source_param = left.strip()
1986+
source_param = (left, mid, right)
19831987

19841988
# Get source element
1985-
source_locator = await PlaywrightLocator.Get_Element(source_param, current_page, frame_locator=_get_frame_locator())
1989+
source_locator = await PlaywrightLocator.Get_Element([source_param], current_page, frame_locator=_get_frame_locator())
19861990
if source_locator == "zeuz_failed":
19871991
CommonUtil.ExecLog(sModuleInfo, "Source element not found", 3)
19881992
return "zeuz_failed"
19891993

19901994
# Get target element
1991-
target_locator = await PlaywrightLocator.Get_Element(target_param, current_page, frame_locator=_get_frame_locator())
1995+
target_locator = await PlaywrightLocator.Get_Element([target_param], current_page, frame_locator=_get_frame_locator())
19921996
if target_locator == "zeuz_failed":
19931997
CommonUtil.ExecLog(sModuleInfo, "Target element not found", 3)
19941998
return "zeuz_failed"

Framework/Built_In_Automation/Web/Playwright/locator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def _parse_element_params(step_data):
199199
params['wait'] = float(right_stripped)
200200

201201
# Element parameters
202-
elif mid_lower == "element parameter":
202+
elif mid_lower == "element parameter" or "element parameter" in mid_lower:
203203
if left_lower == "index":
204204
try:
205205
params['index'] = int(right_stripped)
@@ -303,8 +303,8 @@ def _build_locator(page, step_data, params, frame_locator=None):
303303
if left_lower in ("css", "css selector", "css_selector"):
304304
return base_locator.locator(right)
305305

306-
# Strategy 2: Check for unique parameters
307-
for left, right in params['unique_params']:
306+
# Strategy 2: Check for unique parameters and element parameters
307+
for left, right in params['unique_params'] + params['element_params']:
308308
left_lower = left.lower()
309309

310310
if left_lower == "id":

0 commit comments

Comments
 (0)