AnandDuddella
Programmer
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
==================================================================
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