Iframe issue on katalon

How do we deal with the situation where the web element is in a frame - which is within an iFrame
When do ‘SwitchtoFrame’ - do we have to use the keyword for iFrame/Frame or both? I tried all 3 possibilities but it seems to not able to find the iFrame using any xpath/attruibutes.

Any thoughts?

Hi @anishas,
Remove the 5 second Delay.
Change the ‘Switch To Frame - frame_Contribution Receivables’ to 30 seconds or more.
Remove the second ‘Switch To Frame - frame’
Retry the test.

Alternatively this might help…
Create your self a new test object
Right click on Object Repository > New > Test Object
Create ‘testIframe’ for example

Click on the ‘Xpath’ tab and set the value to //iframe or (//iframe)[1] or (//iframe)[2] if you have 2 iframes, save the object.

Add the following to the test case body:

// Switches to iframe
WebUI.switchToFrame(findTestObject('Object Repository/testIframe'), 90)
// Your code ...
// Switches from iframe

This link may help too: How to (manually) work with iframes in Katalon

Hi I will rephrase - my object (New Invoice button) is within a Frame (which is within the iFrame)

When I use the Object Spy - it identifies the object and iframe correctly
For the iFrame_Contribution Receivables - I cannot use the xpath ID (ext-gen5877) as a locator since the value changes with every run
And there is a frame within the iframe

So I have to SwitchTo ‘iFrame’ or ‘Frame’?
Why Katalon cannot find the Frame or iFrame?

Hi @anishas,
This might help you…
Update your ‘Iframe_Contribution_Receivables’ object as follows: You might need to play with the values. For example, if there is more than one iframe object on your page you could use (//frame)[1] or (//frame)[2] or (//frame)[3]… Using option two would allow you to pick the second iframe.

This might help too:

Body of your test case:

// Waits up-to 10 seconds to switch to iframe (increase wait time if needed).
WebUI.switchToFrame(findTestObject('Object Repository/Iframe_Contribution_Receivables'), 10)
// Your code goes here ...
WebUI.waitForElementPresent(findTestObject('Object Repository/NewInvoiceBtn'), 10)
WebUI.enhancedClick(findTestObject('Object Repository/NewInvoiceBtn'))
// Switches from iframe to main page

Thank you so much for your help

Some more question in continuation of iFrame issue
I seem to manage to switch to the iframe and find the object as well
Below are my steps


However, when I try to look up in my input field - it doesnt match any value. I expect that on setting the text “112006” - a drop down list is populated and I select from the list. What am I doing wrong here?


Hi @anishas, great news that the iFrame is now working for you… If you manually input 112006 what do u see? Also please include a screenshot of your html code and object you are working with.

Hi @anishas,
Also if you are working with dropdowns you should check out these links:

Hi All,

Thank you so much for your help so far!!
Just wanted to provide more information about the same

This is my expected result when I enter the value ‘112006’ in the lookup field - this is not a drop down. User has to manually enter the value and the drop down list is auto populated from which user can select the value


However, in automation - what I get is - where the field just fails to find the value


Just to revise - my object is within a frame - which in turn is within an iframe as below


If I switched to iframe - iframe_AssetEntry - it wouldn’t work
So I switched to Frame - frame_AssetEntry


And I have set the iframe “iframe_Asset entry” to be a parent iframe for the frame “frame_AssetEntry”

And the object itself - input_Lookup - I have set to NOT have any parent object
I assume that since we are already in the frame - we no longer need to specify that the object - input_Lookup - is within a parent object. Not sure if my assumption is correct though!


And this is how it ends up finding the object input_Lookup

However, when I input the text ‘112006’ to start the lookup - it doesn’t find anything


What am I getting wrong here?

Can I make a suggestion - try changing row 36 to use WebUI.sendKeys instead of setText. Using send keys is a better match to how the user enters text and some of these components are sensitive to how values are entered eg if some events are triggered by typing

And it may not hurt to add an <Enter> key afterwards.

import org.openqa.selenium.Keys as Keys

WebUI.sendKeys(findTestObject('myPage/input_Lookup'), '112006')
WebUI.sendKeys(findTestObject('myPage/input_Lookup'), Keys.chord(Keys.ENTER))

You might also need to click into the field.

import org.openqa.selenium.Keys as Keys

WebUI.sendKeys(findTestObject('myPage/input_Lookup'), '112006')
WebUI.sendKeys(findTestObject('myPage/input_Lookup'), Keys.chord(Keys.ENTER))