Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to access the dom object always

Status
Not open for further replies.

AnandDuddella

Programmer
Apr 6, 2011
7
GB
Hi I am using Vb Script and trying to obtain the DOM document object(Page object) and my function does not have access to the page object always. Some times it throws up a run time error "Access Denied" however the page is already loaded.following is the code

==================================================================
Function GetPageObject()

Dim PageObj
Dim PgName
Dim pageURL : pageURL = ""
Dim Page : Set Page = Nothing
Dim Obj : Set Obj = Nothing
Dim Counter : Counter = 5
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))) Then
If InStr(LCase(PageObj(UBound(PageObj)).URL),LCase(" > 0 THEN
aqUtils.Delay 2000
On Error Resume Next
Counter = 5
Do
If Counter = 0 Then
Exit Do
End If
Counter = Counter - 1
Delay 2000
Call Log.Message("Main Account Page URL" & PageObj(UBound(PageObj)).url)
Set Obj = PageObj(UBound(PageObj)).zDocument.frames("TOPFRAME").document
Set GetPageObject = Obj
If NOT Obj Is Nothing Then
EXIT Function
End If
Loop While Obj Is Nothing
Call Log.Message("Main Account Page URL" & PageObj(UBound(PageObj)).url)
Set Obj = PageObj(UBound(PageObj)).zDocument.frames("TOPFRAME").document
Set GetPageObject = Obj
EXIT Function
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
Else
Set obj = PageObj(UBound(PageObj)).zDocument
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
End 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

==================================================================

Is there any other way to obtain the page object using Vb script

Thank you in Advance for your support
Anand
 
What are Sys.Process, aqUtils.Delay, Log.Message, ... ?
Are you sure you use VBScript ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Those are test Complete which is a automation tool used for automation testing

Sys.process() get the process object
aqUtils.Delay delays the program execution by milli seconds
log.message() logs any message into the tool console
 
it throws up a run time error "Access Denied"
At which line of code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Set Obj = PageObj(UBound(PageObj)).zDocument.frames("TOPFRAME").document

When you are accessing the PageObj(UBound(PageObj)).zDocument

ZDocument is the property of IE to access the DOm document but it was renamed as Zdocument

This was the message i got from the Test Complete Support forums.

As this particular page has frame the normal structure of HTML is as below
<!-- frames -->

<frameset rows="*,0">
<frame name="TOPFRAME" src="cus_acct_ud_status1_jpw.asp?ID=4039376" marginwidth="0" marginheight="0" scrolling="yes" frameborder="0" noresize>
<frame name="PROCFRAME" src="_blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
</frameset>

The frame TOPFRAME under this again we have
<html>
<head>
<body>

which actually are loaded when the page gets fully loaded.

BUt only this particular page complains with an error access denied as this is the only page which has frames in it

I have also tried re-installing the IE 8 but the problem still persists

Thank you for your support
Regards
Anand


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top