Forum Discussion

AlSlad's avatar
AlSlad
Occasional Contributor
8 years ago
Solved

Intermittent 'permission denied' error on checking of contentDocument property of frames

Hi there. I encounter an intermittent issue while trying to check contentDocument property of Frame object of a web page. Test runs in IE 11.

 

Here's the piece of code

 

....

this.page.WaitFrame("list",Project.Variables.WAIT_TIME);
while(this.page.Frame("list").contentDocument.readyState != "complete")
{
        Delay(Project.Variables.WAIT_TIME/2,"Loading list...");
};

....

Some frames are filled with child elements and the idea behind of that Delay inside the loop is to wait for entire frame fully loaded before going further.

From time to time I get 'permission denied' error in the test log that points to that 'while' statement. I assume it is related to access to contentDocument property. The issue is intermittent but it happens only for Frame object. I never got it for Page object.

 

I would appreciate if anyone has any idea how to get rid of it. Or maybe someone had encountered the same issue and could fix it.

Thanks.

  • 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
    
  • AlSlad's avatar
    AlSlad
    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.

3 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    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
    
    • AlSlad's avatar
      AlSlad
      Occasional Contributor

      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.

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        FYI, the varNNN constants now live in the aqObject object but can be used without the object name:

        aqObject.varDispatch
        varDispatch