Intermittent 'permission denied' error on checking of contentDocument property of frames
- 8 years ago
Hi,
The following piece of code (VBScript) helped me to significantly decrease the number of problems with access to the contentDocument. Quite rarely the problem may occur, but pretty rarely I can say. Hope, it will help.
Do Until aqObject.IsSupported(PageObject, "contentDocument") Call aqUtils.Delay(500, strMsg) Loop Do Until BuiltIn.varDispatch = aqObject.GetVarType(PageObject.contentDocument) 'PageObject.contentDocument Is Nothing Call aqUtils.Delay(500, strMsg) Loop Do Until aqObject.IsSupported(PageObject.contentDocument, "readyState") Call aqUtils.Delay(500, strMsg) Loop ' !!!=== Workaround for the strange problem with PageObject.contentDocument ===!!! On Error Resume Next Do Until BuiltIn.varOleStr = aqObject.GetVarType(PageObject.contentDocument.readyState) Call aqUtils.Delay(500, strMsg) Loop Do Until "complete" = PageObject.contentDocument.readyState Call aqUtils.Delay(500, strMsg) Loop On Error GoTo 0
- 8 years ago
Hi,
I applied AlexKaras' solution to my scripts without BuiltIn.varDispartch as it's marked as obsolete in TC12.
function WaitUntilLoaded(object, message) { while(!aqObject.IsSupported(object,"contentDocument")) { Delay(Project.Variables.WAIT_TIME,"Waiting for contentDocument..."); } while(!aqObject.IsSupported(object.contentDocument,"readyState")) { Delay(Project.Variables.WAIT_TIME,"Waiting for readyState..."); } while(object.contentDocument.readyState != "complete") { Delay(Project.Variables.WAIT_TIME,message); }; }
I added this function to all page initializations. I have been running test procedures over few days and I have not experienced 'permission denied' error. So I can say it works fine. I could say 'perfectly' if sometimes function didn't go into the infinite loop on first 'contentDocument' check. It happens quite rarely.
Many thanks to AlexKaras. I wouldn't find myself that IsSupported property changes its value on frame loading and can be used this way.