Avoid Losing Window/Frame Context When Handling Alerts

Over the last few days I ran into a problem with my test case. Long story short, my webpage does validation on input boxes and if a validation triggers, it pops up a box asking the user to confirm or deny.

The problem was that once the alert was triggered I could no longer interact with any of the objects on the screen.

This would work perfectly, but once the alert was triggered it wouldnt work anymore.
WebUI.setText( findTestObject(‘Object Repository/test4/Page_/input_Address_ApplicantAddress2’) , ‘john555’)

I tried switching to the iframe and then trying to work with the object, but nothing worked.
I tried calling the iframe by index, that didnt work either. The problem was the alert was being called by another parent window and Katalon was losing focus.

Long story short, give this a try next time you are losing focus with iframes. it solved my issue and I hope it helps other out.

WebUI.switchToDefaultContent()
2 Likes

Hi @johnphughesspam,

Thanks for sharing your work. I moved this topic to Tips and Tricks category.