IFrame Handling error

Hi All,
I want to handle the iframe items as part of my test
When i am using switchtoframe option i am getting below error. please suggest on this
Element code:

<div tabindex="-1" role="dialog" style="position: fixed; height: auto; width: 900px; top: 80.5px; left: 510px; max-width: 100%;" class="ui-dialog ui-corner-all ui-widget ui-widget-content ui-front ui-dialog--apex no-close ui-draggable" aria-describedby="apex_dialog_1" aria-labelledby="ui-id-1"><div class="ui-dialog-titlebar ui-corner-all ui-widget-header ui-helper-clearfix ui-draggable-handle"><span id="ui-id-1" class="ui-dialog-title">Referral Change Status</span><button type="button" class="ui-button ui-corner-all ui-widget ui-button-icon-only ui-dialog-titlebar-close" title="Close"><span class="ui-button-icon ui-icon ui-icon-closethick"></span><span class="ui-button-icon-space"> </span>Close</button></div><div id="apex_dialog_1" class="ui-dialog-content ui-widget-content" style="width: auto; min-height: 0px; max-height: none; height: 351px;"><iframe src="f?p=101:219:7051738629929::NO:RP,219:P219_SERVICE_REQUEST_ID,P219_SR_STATUS_TO_IGNORE:3774,2735&amp;p_dialog_cs=OI4YBiz5I1MWlV1TidcrPYURCHAeWvMj1Tk7ZNYzOEqQF7WJM-YOZUhS0J6rsQZRe92mSWZdHIII1wQL6u1bMA" title="Referral Change Status" width="100%" height="100%" style="min-width: 95%;height:100%;" scrolling="auto"></iframe></div></div>
My code:

WebUI.switchToFrame(findTestObject(‘Page_Client Referrals/iframe’), 10)

WebUI.setText(findTestObject(‘Page_Client Referrals/Referral_change_status_text’), ‘Automation testing’)
Oject


Error
2019-06-27 14:06:14.008 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to verify image ‘Object Repository/Page_Client Referrals/iframe’ present (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to verify image ‘Object Repository/Page_Client Referrals/iframe’ present
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.SwitchToFrameKeyword.switchToFrame(SwitchToFrameKeyword.groovy:84)
at com.kms.katalon.core.webui.keyword.builtin.SwitchToFrameKeyword.execute(SwitchToFrameKeyword.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.switchToFrame(WebUiBuiltInKeywords.groovy:2869)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$switchToFrame$5.call(Unknown Source)
at Search,set focus and Service completion.run(Search,set focus and Service completion:66)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:133)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:116)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:83)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1561640735352.run(TempTestSuite1561640735352.groovy:35)
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Page_Client Referrals/iframe’ located by ‘By.xpath: //[@id=“apex_dialog_2”]/iframe’ not found
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1097)
at com.kms.katalon.core.webui.keyword.builtin.SwitchToFrameKeyword$_switchToFrame_closure1.doCall(SwitchToFrameKeyword.groovy:77)
at com.kms.katalon.core.webui.keyword.builtin.SwitchToFrameKeyword$_switchToFrame_closure1.call(SwitchToFrameKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
at com.kms.katalon.core.webui.keyword.builtin.SwitchToFrameKeyword.switchToFrame(SwitchToFrameKeyword.groovy:84)
at com.kms.katalon.core.webui.keyword.builtin.SwitchToFrameKeyword.execute(SwitchToFrameKeyword.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.switchToFrame(WebUiBuiltInKeywords.groovy:2869)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$switchToFrame$5.call(Unknown Source)
at Script1561467799535.run(Script1561467799535.groovy:66)
… 13 more
)
2019-06-27 14:06:14.009 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Emma_AddNewClient/Search,set focus and Service completion FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to verify image ‘Object Repository/Page_Client Referrals/iframe’ present
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.SwitchToFrameKeyword.switchToFrame(SwitchToFrameKeyword.groovy:84)
at com.kms.katalon.core.webui.keyword.builtin.SwitchToFrameKeyword.execute(SwitchToFrameKeyword.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.switchToFrame(WebUiBuiltInKeywords.groovy:2869)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$switchToFrame$5.call(Unknown Source)
at Search,set focus and Service completion.run(Search,set focus and Service completion:66)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:133)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:116)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:83)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1561640735352.run(TempTestSuite1561640735352.groovy:35)
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Page_Client Referrals/iframe’ located by 'By.xpath: //
[@id=“apex_dialog_2”]/iframe’ not found
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1097)
at com.kms.katalon.core.webui.keyword.builtin.SwitchToFrameKeyword$_switchToFrame_closure1.doCall(SwitchToFrameKeyword.groovy:77)
at com.kms.katalon.core.webui.keyword.builtin.SwitchToFrameKeyword$_switchToFrame_closure1.call(SwitchToFrameKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
… 19 more

This is the relevant part of your error. You should test your xpath in the browser console:

1.) While you are on the target page, press F12 to open the inspector.
2.) Open the “Console” tab.
3.) Enter the following into the console and see what you get back:

$x(“//*[@id=“apex_dialog_2”]/iframe”)

Are you working with nested iframes? If so, you will need to switch to all of the parent frames in the hierarchy first before you switch to the target one.

Note: when you share html code, it’s often easier to read when it’s formatted. You can either pretty print it, or just post a screenshot from the inspector.

1 Like

Hi Brandon,
Thank you for your details :slight_smile: Yes your rite i am dealing with nested one and i have used the recording to capture the exact obj repo and placed that in my code. and its working fine