Skip to content

Commit eb4a9ae

Browse files
Merge pull request #213 from AutomationSolutionz/frame-parameter-support
Frame Parameter Support
2 parents dcd7746 + 9af180e commit eb4a9ae

File tree

4 files changed

+85
-38
lines changed

4 files changed

+85
-38
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Changelog
22

3-
### [16.1.0][Jun 07, 2022]
4-
- **[Add]** Basic performance testing functions for rest calls
53

64
# Version 16
75

86
### [Current changes]
7+
- **[Add]** 'frame parameter' support is added into Switch_Iframe action
8+
- **[Add]** Basic performance testing functions for rest calls
99
- **[Add]** Added selenium grid functionality. Usage:
1010
```shell
1111
cd .../Framework/Built_In_Automation/Web/Selenium

Framework/Built_In_Automation/Sequential_Actions/action_declarations/info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"destination element parameter", "destination parent parameter", "destination sibling parameter", "destination child parameter",
5555
"optional parameter",
5656
"iframe parameter",
57+
"frame parameter",
5758
"method",
5859
"url",
5960
"body",

Framework/Built_In_Automation/Sequential_Actions/sequential_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Add to the actions dictionary - module and name must be lowercase with single spaces, function should be the exact spelling of the function name
88
99
Adding new Sub-Field keywords
10-
Add to the action_suport list - must be lowercase with single spaces
10+
Add to the action_support list - must be lowercase with single spaces
1111
1212
Adding a new dynamically called module
1313
Add to the load_sa_modules() function, follow same format as other sections

Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py

Lines changed: 81 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ def Go_To_Link(step_data, page_title=False):
826826

827827
# options for add_argument or add_extension etc
828828
browser_options = []
829-
829+
830830
# Open browser and create driver if user has not already done so
831831
global dependency
832832
global selenium_driver
@@ -3756,54 +3756,100 @@ def switch_iframe(step_data):
37563756
selenium_driver.switch_to.default_content()
37573757
CommonUtil.ExecLog(sModuleInfo, "Exited all iframes and switched to default content", 1)
37583758
elif left == "index":
3759-
for i in range(5):
3760-
iframes = selenium_driver.find_elements_by_tag_name("iframe")
3761-
idx = int(right.strip())
3762-
if -len(iframes) <= idx < len(iframes):
3763-
CommonUtil.ExecLog(sModuleInfo, "Iframe switched to index %s" % right.strip(), 1)
3764-
break
3765-
CommonUtil.ExecLog(sModuleInfo, "Iframe index = %s not found. retrying after 2 sec wait" % right.strip(), 2)
3766-
time.sleep(2)
3767-
else:
3768-
CommonUtil.ExecLog(sModuleInfo, "Index out of range. Total %s iframes found." % len(iframes), 3)
3769-
return "zeuz_failed"
3770-
if idx < 0:
3771-
idx = len(iframes) + idx
3772-
try:
3773-
frame_attribute = iframes[idx].get_attribute('outerHTML')
3774-
i, c = 0, 0
3775-
for i in range(len(frame_attribute)):
3776-
if frame_attribute[i] == '"':
3777-
c += 1
3778-
if (frame_attribute[i] == ">" and c % 2 == 0):
3759+
if mid == "iframe parameter":
3760+
for i in range(5):
3761+
iframes = selenium_driver.find_elements(By.TAG_NAME, "iframe")
3762+
idx = int(right.strip())
3763+
if -len(iframes) <= idx < len(iframes):
3764+
CommonUtil.ExecLog(sModuleInfo, "Iframe switched to index %s" % right.strip(), 1)
37793765
break
3780-
frame_attribute = frame_attribute[:i+1]
3781-
CommonUtil.ExecLog(sModuleInfo, "%s" % (frame_attribute), 5)
3782-
except:
3783-
pass
3784-
selenium_driver.switch_to.frame(idx)
3766+
CommonUtil.ExecLog(sModuleInfo,
3767+
"Iframe index = %s not found. retrying after 2 sec wait" % right.strip(), 2)
3768+
time.sleep(2)
3769+
else:
3770+
CommonUtil.ExecLog(sModuleInfo, "Index out of range. Total %s iframes found." % len(iframes), 3)
3771+
return "zeuz_failed"
3772+
if idx < 0:
3773+
idx = len(iframes) + idx
3774+
try:
3775+
frame_attribute = iframes[idx].get_attribute('outerHTML')
3776+
i, c = 0, 0
3777+
for i in range(len(frame_attribute)):
3778+
if frame_attribute[i] == '"':
3779+
c += 1
3780+
if (frame_attribute[i] == ">" and c % 2 == 0):
3781+
break
3782+
frame_attribute = frame_attribute[:i + 1]
3783+
CommonUtil.ExecLog(sModuleInfo, "%s" % (frame_attribute), 5)
3784+
except:
3785+
pass
3786+
selenium_driver.switch_to.frame(idx)
3787+
elif mid == "frame parameter":
3788+
for i in range(5):
3789+
frames = selenium_driver.find_elements(By.TAG_NAME, "frame")
3790+
idx = int(right.strip())
3791+
if -len(frames) <= idx < len(frames):
3792+
CommonUtil.ExecLog(sModuleInfo, "Frame switched to index %s" % right.strip(), 1)
3793+
break
3794+
CommonUtil.ExecLog(sModuleInfo,
3795+
"Frame index = %s not found. retrying after 2 sec wait" % right.strip(), 2)
3796+
time.sleep(2)
3797+
else:
3798+
CommonUtil.ExecLog(sModuleInfo, "Index out of range. Total %s frames found." % len(frames), 3)
3799+
return "zeuz_failed"
3800+
if idx < 0:
3801+
idx = len(frames) + idx
3802+
try:
3803+
frame_attribute = frames[idx].get_attribute('outerHTML')
3804+
i, c = 0, 0
3805+
for i in range(len(frame_attribute)):
3806+
if frame_attribute[i] == '"':
3807+
c += 1
3808+
if (frame_attribute[i] == ">" and c % 2 == 0):
3809+
break
3810+
frame_attribute = frame_attribute[:i + 1]
3811+
CommonUtil.ExecLog(sModuleInfo, "%s" % (frame_attribute), 5)
3812+
except:
3813+
pass
3814+
selenium_driver.switch_to.frame(idx)
37853815

37863816
elif "default" in right.lower():
37873817
try:
37883818
iframe_data = [(left, "element parameter", right)]
37893819
if left != "xpath":
3790-
iframe_data.append(("tag", "element parameter", "iframe"))
3791-
Element = LocateElement.Get_Element(iframe_data, selenium_driver)
3792-
selenium_driver.switch_to.frame(Element)
3820+
if mid == "iframe parameter":
3821+
iframe_data.append(("tag", "element parameter", "iframe"))
3822+
elif mid == "frame parameter":
3823+
iframe_data.append(("tag", "element parameter", "frame"))
3824+
element = LocateElement.Get_Element(iframe_data, selenium_driver)
3825+
selenium_driver.switch_to.frame(element)
37933826
CommonUtil.ExecLog(sModuleInfo, "Iframe switched using above Xpath", 1)
37943827
except:
3795-
CommonUtil.ExecLog(sModuleInfo, "No such iframe found. Exited all iframes and switched to default content", 2)
3828+
if mid == "iframe parameter":
3829+
CommonUtil.ExecLog(sModuleInfo,
3830+
"No such iframe found. Exited all iframes and switched to default content",
3831+
2)
3832+
elif mid == "frame parameter":
3833+
CommonUtil.ExecLog(sModuleInfo,
3834+
"No such frame found. Exited all frames and switched to default content",
3835+
2)
37963836
selenium_driver.switch_to.default_content()
37973837
else:
37983838
try:
37993839
iframe_data = [(left, "element parameter", right)]
38003840
if left != "xpath":
3801-
iframe_data.append(("tag", "element parameter", "iframe"))
3802-
Element = LocateElement.Get_Element(iframe_data, selenium_driver)
3803-
selenium_driver.switch_to.frame(Element)
3841+
if mid == "iframe parameter":
3842+
iframe_data.append(("tag", "element parameter", "iframe"))
3843+
elif mid == "frame parameter":
3844+
iframe_data.append(("tag", "element parameter", "frame"))
3845+
element = LocateElement.Get_Element(iframe_data, selenium_driver)
3846+
selenium_driver.switch_to.frame(element)
38043847
CommonUtil.ExecLog(sModuleInfo, "Iframe switched using above Xpath", 1)
38053848
except:
3806-
CommonUtil.ExecLog(sModuleInfo, "No such iframe found using above Xpath", 3)
3849+
if mid == "iframe parameter":
3850+
CommonUtil.ExecLog(sModuleInfo, "No such iframe found using above Xpath", 3)
3851+
elif mid == "frame parameter":
3852+
CommonUtil.ExecLog(sModuleInfo, "No such frame found using above Xpath", 3)
38073853
return "zeuz_failed"
38083854
return "passed"
38093855
except Exception:
@@ -4455,4 +4501,4 @@ def multiple_check_uncheck(data_set):
44554501
else:
44564502
CommonUtil.ExecLog("", str(targets[i]) + " couldn't be unchecked so skipped it", 3)
44574503

4458-
return "passed"
4504+
return "passed"

0 commit comments

Comments
 (0)