Forum Discussion

aduddella's avatar
aduddella
Contributor
14 years ago

Page access denied but not everytime



Hi



I am using the following piece of code to access the dom page structure and it works most of the times but suddeny it throws an error stating that the access is denied



really not able to understand why this happens



CODE




Function GetPageObject()


Dim PageObj ': PageObj = Array()


Dim PgName


Dim pageURL : pageURL = ""


Dim Page : Set Page = NothingDim Obj : Set Obj = Nothing


Dim Counter : Counter = 5


' Verify whether an arbitrary


' or specific (with the given URL) Page object is needed


If (pageURL="")Then


pageURL="*"


Else


pageURL="*" & pageURL & "*"


End If


PgName="Page(" & pageURL & ")"


Sys.Process("iexplore", 2).Refresh


 


Set Page = Sys.Process("iexplore",2)


 


' Search for the child objects of the browser Process


PageObj = Page.FindAllChildren("Name",PgName,60)If UBound(PageObj) <> -1 Then


If IsObject(PageObj(UBound(PageObj))) ThenIf InStr(LCase(PageObj(UBound(PageObj)).URL),LCase("http://crmtest.xln/cust_acct_frame.asp")) > 0 THENaqUtils.Delay 2000


' Sys.Process("iexplore", 2).Refresh


 


On Error Resume Next


Counter = 5


Do


If Counter = 0 Then


Exit Do


End If


Counter = Counter - 1


Delay 500


Set Obj = PageObj(UBound(PageObj)).zDocument.frames("TOPFRAME").document


Set GetPageObject = Obj


If NOT Obj Is Nothing ThenEXIT FunctionEnd If


Loop While Obj Is Nothing


Set Obj = PageObj(UBound(PageObj)).zDocument.frames("TOPFRAME").document


Set GetPageObject = Obj


EXIT FunctionIf (Not PageObj(UBound(PageObj)).Exists) ThenLog.Error("The Page(" & pageURL & ") object was not found.")


Set GetPageObject=NothingElseSet GetPageObject=Obj


End IfElse


Set obj = PageObj(UBound(PageObj)).zDocument


If (Not PageObj(UBound(PageObj)).Exists) ThenLog.Error("The Page(" & pageURL & ") object was not found.")


Set GetPageObject=NothingElseSet GetPageObject=Obj


End IfEnd If


End If ' End of if to check that PageObject is a Object


Else


Log.Warning(" Unable to get the Page Object ") End If ' End of if to check that PageObject Exists


End Function



I have under bolded and underlined the code at which it occurs but at the same time if i F12 in IE I can see the DOM strucure in the developer tools so really can not understand why Test Complete is unable to access



Any help would be much appreciated



Regards

Anand

6 Replies


  • Hi Anand,





    First of all, please try retrieving the needed frame object via TestComplete's objects tree instead of using in-browser native objects - for example, you can use the FindChild method with the "ObjectType = Frame" and "ObjectIdentifier = TOPFRAME" criteria to retrieve the needed frame. If this suggestion does not help, please post an image showing the specific error message you get to this thread. Also, please let us know what version of IE you use.


  • Dear Allen 



    Thank you for the suggestion 



    My problem is when i try to use test complete find method i can get the frame object but what i need is the DOM document object by which I can search for objects using native dom methods 



    So following your suggestion I am getting a dom document with the following code but this does not have any of the innerhtml code 








      Sys.Process("iexplore", 2).Refresh

        

      Set Page = Sys.Process("iexplore",2)

     

      ' Search for the child objects of the browser Process 

       PageObj = Page.FindAllChildren("Name",PgName,60)

    If UBound(PageObj) <> -1 Then 

     If IsObject(PageObj(UBound(PageObj))) Then

      If InStr(LCase(PageObj(UBound(PageObj)).URL),LCase("https://crmtest.xlntelecom.co.uk/cust_acct_frame.asp")) > 0  THEN

          aqUtils.Delay 2000

          

           Set frameObject = PageObj(UBound(PageObj)).find("name","frame(*)",10)(0)

           Set Obj = frameObject.document

        If (Not PageObj(UBound(PageObj)).Exists) Then

          Log.Error("The Page(" & pageURL & ") object was not found.")

          Set GetPageObject=Nothing

        Else

          Set GetPageObject=Obj

        End If


           Set Obj = frameObject.document

    This command give me the access to dom document object but it does not have any child nodes in it 



    I have attached the html page source for your view and the document objects which i want to access are dynamic which get loaded in a frame but some times i get an access and most of the times it always throws an error saying access denied whereas i can see that the page is already loaded 



    earlier I was using SYS.PROCESS(IEXPLORE).PAGEOBJECT.ZDOCUMENT.FRAME("NAME").DOCUMENT



    But this does not work always .



    Any more suggestion would be greatly appreciated 

    Regards

    Anand















  • Hi Anand,





    The HTML source you provided contains just a frame referring to "cus_acct_ud_status1_jpw.asp?ID=4039376" - I suppose the full URL is https://crmtest.xlntelecom.co.uk/cus_acct_ud_status1_jpw.asp?ID=4039376, and it is not available for us. Could you please describe why TestComplete methods are not enough for you and why you need to use native DOM methods in your test? I suppose the same task can be achieved with same (or even fewer) efforts with TestComplete methods.





    As for the original problem, please try reinstalling IE - a similar problem is known to be solved this way. If this suggestion does not help, we still need the additional information requested in my previous message.


  • Dear Allen 



    We are currently to build the automation framework prototype.



    In our company the main application is our CRM used by all employees across all departments 



    Our release cycle is every week so things change on the crm everyweek so the option of recording all the regression would not work due the following limitations 



    1. test complete can not capture dynamic menus in recording 

    2. the UI objects can change which would involve maintenance re work

    3. The Scripting Language we use is VB Script where we have the limitation of that objects are passed always by ref and not by value 



    So instead we writing an identification program which would have kind of xpath notation such as 



    if you ask for username it would return you the corresponding to address a value in table and to make checks for data we use notation such as 



    A[B=C] where A is the column name we want to retrieve the value from and B & C are conditions 



    we have to call this function several times in our automation and using native dom function gives us the flexibility and we use test complete to maintain the code and organise our tests 



    I hope I was able to give you a clear scenario as why are we using the native dom functions as the test complete find functions can not find the dynamic menus and they would need us to know the object names and identifiers before hand and our html code is not organised at all as usual it was inheritance passed on to us 



    I will try to re-intsall the IE and let you know if my problem is solved 



    Any suggestions please do let me know 



    Regards

    Anand










  • Dear Allen 



    Even i have tried reinstalling the IE 8 but still the same problem and one another thing i have noticed is that under the object browser I have 3 instances of process("iexplore"),process("iexplore",2),process("iexplore",3)



    But earlier it were only 2 



    Any reason for this behaviour



    Thank you in advance 

    Anand

  • Hi Anand,





    Thanks for the description. The multi-process behavior you observe is caused by the fact that IE 8 creates separate processes for each tab opened in the browser. You can make Internet Explorer launch only one process. To do it, in the system registry, search for the TabProcGrowth value in the HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main key (if it is not present, add the value of the string type) and set it equal to zero. 





    As for the original problem, if the suggestion does not help, we still need the additional information requested in my first message.