It works as it should. Now there are times where a popup could occur when leaving a popup box. So when leaving the input box I have this try/catch
try {
WebUI.acceptAlert()
System.out.println(‘Accept address validation has been accepted’)
}
catch (Exception e) {
System.out.println(‘No address validation alert’)
}
If the alert happens, accept it and continue on. The problem is after accepting the alert, the same code that worked for input data into the input boxes no longer works. It worked before the popup, but wont work after accepting the popup.
WebUI.setText( findTestObject(‘Object Repository/test4/Page_/input_Address_ApplicantAddress2’) , ‘john555’) // doesnt work when executed after the popup.
Here is the error log. Like I said before, I can access test objects just fine if the alert doesnt fire. Accepting the alert works as it should.
=============== ROOT CAUSE =====================
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/test4/Page_/iframe_RTR Quotes_MainIS20test’ located by ‘//iframe[@id=‘MainIS20test’]’ not found
Click here to fix broken Test Object
12-18-2020 04:10:34 PM if (waitForElementPresent(findTestObject(“Object Repository/test4/Page_/td_GeoCodeSuccessful”), 30))
Elapsed time: 31.700s
Unable to wait for object ‘Object Repository/test4/Page_/td_GeoCodeSuccessful’ to be present (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to wait for object ‘Object Repository/test4/Page_/td_GeoCodeSuccessful’ to be 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.WaitForElementPresentKeyword.waitForElementPresent(WaitForElementPresentKeyword.groovy:95)
at com.kms.katalon.core.webui.keyword.builtin.WaitForElementPresentKeyword.execute(WaitForElementPresentKeyword.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.waitForElementPresent(WebUiBuiltInKeywords.groovy:344)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$waitForElementPresent$11.call(Unknown Source)
at test4.run(test4:263)
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:393)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:384)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:363)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:355)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:251)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1608325798585.run(TempTestCase1608325798585.groovy:25)
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/test4/Page_/iframe_RTR Quotes_MainIS20test’ located by ‘//iframe[@id=‘MainIS20test’]’ not found
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1369)
at com.kms.katalon.core.webui.common.WebUiCommonHelper.switchToParentFrame(WebUiCommonHelper.java:1435)
at com.kms.katalon.core.webui.common.WebUiCommonHelper.switchToParentFrame(WebUiCommonHelper.java:1424)
at com.kms.katalon.core.webui.keyword.builtin.WaitForElementPresentKeyword$_waitForElementPresent_closure1.doCall(WaitForElementPresentKeyword.groovy:78)
at com.kms.katalon.core.webui.keyword.builtin.WaitForElementPresentKeyword$_waitForElementPresent_closure1.call(WaitForElementPresentKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
at com.kms.katalon.core.webui.keyword.builtin.WaitForElementPresentKeyword.waitForElementPresent(WaitForElementPresentKeyword.groovy:95)
at com.kms.katalon.core.webui.keyword.builtin.WaitForElementPresentKeyword.execute(WaitForElementPresentKeyword.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.waitForElementPresent(WebUiBuiltInKeywords.groovy:344)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$waitForElementPresent$11.call(Unknown Source)
at Script1605549216498.run(Script1605549216498.groovy:263)
… 10 more
)
Also, I want to say this worked before I upgrade to 7.8, but I cant say for 100%. This is code that I wrote a few months ago, and when I finished it, I am pretty sure it worked if that helps.
So there appears to be an iframe involved. Are you using WebUI.switchToFrame() in this code?
Do you think the page is somehow refreshing after you clear the alert? It sounds as though the element has disappeared (which can happen when the page is refreshed - even partially refreshed).
To find out of the page is being refreshed, watch the network tab in devtools (or the console with XHR messages enabled).
There is an iframe involved.
I am not using WebUI.switchToFrame(), should I be after accepting the alert?
After I accept the alert there is new activity in the Network tab of Chrome Dev tools. It is doing some behind the scenes geocoding verifying an address.
I cleared the console before triggering the alert and the attached image is what happens after I accept the alert.
Thanks in advance!
It’s hard to say if you need it, all I can say is the error is complaining about an element with an xpath using “iframe”. It sounds like the switch is needed - but you insist this used to work. All I can tell you is what I see ← and you’re in control of that part.
This never worked before.
The control you claim is working when the alert does NOT appear is in an iframe.
When the alert appears, it is issued by the outer document (the document that hosts the iframe element).
Once it has gained the focus, webdriver is confused and cannot “see” the iframe.
I’m not 100% sure of any of that. But I DO suspect the issue is something along those lines.
Russ ~
Thank you for your time and attention to this issue!
I think you might be on to something with your last post. I tried adding this line of code after accepting the alert, but it was not successful. This is the main iframe of the project. If it would be helpful, I can share the github repo for you to see first hand?
Is there a way that I can System.out.println the name of the current frame I am in?
This would allow me to compare which frame has focus before and after the alert to see if that is part of the issue?
No worries at all
Thanks for your time for sure. I use to administer forums for a company called appMobi, so I really do appreciate the time you put into it, I know it can be difficult dealing with users sometimes!