Hello,
I have an issue when trying to execute the following BrowserText = BrowserPage.Text i receive a 1258: Ole UnKnown Name. I have another script that does the exact same thing and it works. What is interesting, I can run the script on a WinXP machine and it works. If I try on a Win 7 machine, I get this error.
Here is a portion of the script:
;Internet Explorer is launched...
;--------------------------------
:lnchApp
ignoreinput(@true)
; Create a full screen gradient window if not in Debug mode
ShowScreen = IsKeyDown(@CTRL)
if ShowScreen
display(1, 'Outlook Web SSO', 'Please release the CONTROL key' )
While IsKeyDown(@CTRL) == 1
Display (1, "OutLook Web SSO", 'Please release the CONTROL key' )
endwhile
else
;debug(@on)
BoxesUp("0, 0, 1000, 1000", @ZOOMED)
BoxCaption(1,"OutLook Web Single Sign On")
BoxColor(1,"0,128,0",4)
BoxDrawRect(1, "0, 0, 1000, 1000", 2)
BoxTextColor(1,"255,255,255")
BoxTextFont(1,"Times",30,80,0|0)
BoxDrawText(1,"250,100,750,200","Please wait while the script executes...%@crlf%Today is %time%",@false,1)
;IntControl(54,"Siemens Single Sign On", 1, 0, 0) ; Replaced by WindowOnTop
WindowOnTop("OutLook Web Single Sign On", 1)
endif
astatusbar(0,"Outlook Web Single Sign On","Starting script...",4,0)
timedelay(1)
astatusbar(1,"Outlook Web Single Sign On","Launching browser...",4,1)
timedelay(1)
;debug(@on)
Browser = objectopen("InternetExplorer.Application")
Browser.addressbar = @true
Browser.statusbar = @true
Browser.menubar = @true
Browser.toolbar = @true
Browser.visible = @true
Browser.height = 750
Browser.width = 950
Browser.navigate(appURL)
if (WinWaitExist(SecWin,4) == @TRUE) ; Certificate expired/invalid message
SendKeysTo(SecWin,"y") ; Proceed anyway
if (WinWaitExist (SecWin, 1))
SendKeysTo(SecWin,"{TAB}{TAB}{ENTER}")
if (WinExist(SecWin))
SendKeysTo(SecWin,"!Y")
endif
endif
endif
if (WinWaitExist(SecWin2,1) == @TRUE) ; Certificate expired/invalid message for XP
SendKeysTo(SecWin2,"y") ; Proceed anyway
endif
if ((WinWaitExist(LoginWin,5)) || (WinWaitExist(FinalWin, 5))) ;Internet Explorer launched successfully
if (WinExist (LoginWin))
Return
else
gosub close
endif
else
errMsg = "Didn't find the Login Window - '%LoginWin%', or, else, Unable to launch Internet Explorer..."
Gosub error
endif
Return ;lnchApp
;--------------------------------------------------------------------------------------------------------
; Login to Outlook Web...
;----------------------------
:login
astatusbar(1,"Outlook Web Single Sign On","Logging in to Outlook...",4,2)
TimeDelay(1)
;debug(@on)
BrowserDoc = ""
BrowserBody = ""
BrowserPage = ""
BrowserText = ""
BrowserDoc = Browser.Document
BrowserBody = BrowserDoc.Body
BrowserPage = BrowserBody.CreateTextRange
BrowserText = BrowserPage.Text <--- This is where I get the error.
;/************************ New Code ***********************
hdoc = Browser.document
hLoginForm = hDoc.forms("logonForm")
if (hLoginForm == 0) then
errMsg ("Unable to locate the 'logonForm' on the login screen")
GoTo error
endif
hUserIDField = hLoginForm.elements("username")
if (hUserIDField == 0) then
errMsg = "Unable to locate the 'username' field on the login screen")
GoTo error
endif
hUserIDField.value = user
hUserPWDField = hLoginForm.elements("password")
if (hUserPWDField == 0) then
errMsg = "Unable to locate the 'password' field on the login screen")
GoTo error
endif
hUserPWDField.value = pass
SendKeysTo(LoginWin,"%TAB%%TAB%%@cr%") ; Now that we populated the fields, send enter
;hUserSubmitButton = hLoginForm.elements("isUtf8")
;if (hUserSubmitButton == 0) then
; errMsg = "Unable to locate the 'submit' button on the login screen")
; GoTo error
;endif
;
;hUserSubmitButton.click()
timedelay (1)
;/******************************* End of New Code *************************
The error message is fairly self explanatory. The 'text' property is not supported by the 'body' object. This is suggestive of one of the major issues with attempting to automate Web pages via COM Automation and the document object model. The HTML and Web standards are constantly evolving so the DOM interface changes to match the standards changes. Basically, there are two possible causes for the absents of the 'text' property. One is that the site has been made HTML5 compliant and switched to using CSS to define text attributes and/or MSFT's newer implementations of the DOM no longer supports the 'text' property because the associated HTML attribute is considered 'deprecated' and 'obsolete'.
I am sure one of the many forum members with Web site automation expertise will offer up alternatives.
Neglected to mention that one interesting test is to switch IE to Compatibility mode which may (may not) induce the COM Automation object to support the older body interface that has a 'text' property.
Thank you. That is what I suspected. I will test with Compatibility Mode and see what that produces.
No Joy on campatibility mode. What is interesting, is why one script using the same browserpage.text works and the other does not,. They both run on the same worstations. As you can tell, I'm a novice with WinBatch.
You have changed your story. But If one works and the other doesn't then, obviously, you need to look at the things that might be different about the scripts, including things like user account type, the targeted web site or whatever.
I'm sorry if I was not clear in my problem statement.
"I have an issue when trying to execute the following BrowserText = BrowserPage.Text i receive a 1258: Ole UnKnown Name. I have another script that does the exact same thing and it works. What is interesting, I can run the script on a WinXP machine and it works. If I try on a Win 7 machine, I get this error."
I't is very obvious that I'm not very knowledgeable on WinBatch. We had a developer that just quit with no notice and WinBatch was thrust upon me. The same user would use both WinBatch scripts. One works and the other does not. What would I need to investigate on the targeted website? I will include part of the script that is working:
;Internet Explorer is launched...
;--------------------------------
:lnchApp
Sixtyfour = 0
If DirExist(appDirx86)
appDir = appDirx86
Sixtyfour = 1
Display (1, "Checking for 64 bit", "Setting IE to 32 bit")
endif
ShowScreen = IsKeyDown(@CTRL)
if ShowScreen
display(3, 'Please release the CONTROL key', 'Please release the CONTROL key' )
if IsKeyDown(@CTRL) == 1
message ("Please release the CONTROL key", 'Please release the CONTROL key' )
endif
else
if !(Sixtyfour)
ignoreinput(@true)
; Create a full screen gradient window
else
; BoxesUp("0, 0, 1000, 1000", @ZOOMED)
; BoxCaption(1,"Siemens Single Sign On")
; BoxColor(1,"0,128,0",4)
; BoxDrawRect(1, "0, 0, 1000, 1000", 2)
; BoxTextColor(1,"255,255,255")
; BoxTextFont(1,"Times",30,80,0|0)
; BoxDrawText(1,"250,100,750,200","Please wait while the script executes...%@crlf%Today is %time%",@false,1)
; IntControl(54,"Siemens Single Sign On", 1, 0, 0)
endif
endif
astatusbar(0,"QuickChart Web Single Sign On","Starting script...",4,0)
timedelay(1)
astatusbar(1,"QuickChart Web Single Sign On","Launching browser...",4,1)
timedelay(1)
Browser = objectopen("InternetExplorer.Application")
Browser.addressbar = @true
Browser.statusbar = @true
Browser.menubar = @true
Browser.toolbar = @true
Browser.visible = @true
Browser.navigate(appURL)
timedelay(1)
timer = 0
while !( (WinExist(SecWin)) || (WinExist(SecWin2)) || (WinExist(LoginWin)) ) && (timer < 20)
timer = timer + 1
if timer == 5 || timer == 10 || timer == 15 || timer == 20
display(1, 'QuickChart SSO - Waiting for Login Window', 'Waiting for Login Window to Appear%Enter%%Enter%Elapsed time is %timer% seconds')
else
timedelay(1)
endif
endwhile
FoundSecurity = 0
if (WinExist(SecWin) == @TRUE) ; Certificate expired/invalid message
SendKeysTo(SecWin,"y") ; Proceed anyway
If (WinWaitExist(SecWin,1) == @TRUE)
SendKeysTo(SecWin, "{ENTER}")
endif
FoundSecurity = 1
endif
if (WinExist(SecWin2) == @TRUE) ; Certificate expired/invalid message for XP
SendKeysTo(SecWin2,"y") ; Proceed anyway
if (WinWaitExist(SecWin2,1))
SendKeysTo(SecWin2, "{TAB}{ENTER}")
endif
FoundSecurity = 1
endif
if FoundSecurity == 1
Wait_Time = 15
else
Wait_Time = 10
endif
elapsed = Timer
i = 0
While i < 10 ; This loop will potentially run for 120 seconds, but the user can stop it at 1 minute intervals!
if !(WinExist (LoginWin))
i = i + 1
j = 0
while (!(WinExist (LoginWin)) && (j < 2))
if ShowScreen
elapsed = elapsed + 5
timedelay(4)
if (elapsed != 60) && (elapsed != 120)
display(1, 'QuickChart SSO - Waiting for Login Window', 'Waiting for Login Window to Appear%Enter%%Enter%Elapsed time is %elapsed% seconds')
endif
else
elapsed = elapsed + 5
timedelay (4)
if (elapsed != 30) && (elapsed != 60) && (elapsed != 120)
display(1, 'QuickChart SSO - Waiting for Login Window', 'Waiting for Login Window to Appear%Enter%%Enter%Elapsed time is %elapsed% seconds')
endif
endif
j = j + 1
endwhile
if (i == 1) || (i == 4)
timeamount = i * 10 + 20
stringmsg1 = strcat ('It has been ', timeamount, ' seconds and the QuickChart ')
if i == 1
stringmsg2 = "Login screen has not appeared!%ENTER%%ENTER%"
else
stringmsg2 = "Login screen has still not appeared!%ENTER%%ENTER%"
endif
stringmsg3 = 'If you want to Continue with the QuickChart single sign on (SSO), please press "OK".%ENTER%'
stringmsg4 = 'To terminate the SSO, please press "Cancel"'
; stringmsg4 = 'To terminate the SSO, please press "NO" or "Cancel"'
; q = AskYesNo('Continue Loading QuickChart', strcat(stringmsg1, stringmsg2, stringmsg3, stringmsg4))
; If q != @YES Then Exit
Pause('Continue Loading QuickChart' , strcat(stringmsg1, stringmsg2, stringmsg3, stringmsg4) )
endif
else
break
endif
EndWhile
if WinExist(LoginWin) == @TRUE ;Internet Explorer launched successfully
Return
else
errMsg1 = "It has been %elapsed% seconds, and the QuickChart Login window has still not appeared.%ENTER%"
errMsg2 = "There may be a temporary problem with QuickChart or an intermittent network problem.%ENTER%%ENTER%"
errMsg3 = "You may want to try launching the Dashboard QuickChart single sign on (SSO) again.%ENTER%%ENTER%%ENTER%"
errMsg4 = "However, if the problem continues, please call the St. Luke's IT Help Desk at 381-4357.%ENTER%"
errMsg = StrCat(errMsg1, errMsg2, errMsg3, errMsg4)
Gosub error
endif
;Browser = objectopen("InternetExplorer.Application")
; Browser.addressbar = @true
; Browser.statusbar = @true
; Browser.menubar = @true
; Browser.toolbar = @true
; Browser.visible = @true
; Browser.navigate(appURL)
;;while (Browser.readystate <> 4)
;; TimeDelay(1)
;;endwhile
Return ;lnchApp
;--------------------------------------------------------------------------------------------------------
; Login to QuickChart Web...
;----------------------------
:login
astatusbar(1,"QuickChart Web Single Sign On","Logging in to QuickChart3...",4,2)
TimeDelay(1)
IntControl (35, 200, 200, 0, 0)
if WinExist(FinalWin) ; Check for the Final Window in case a SSO product, such as OneSign, has already logged into QuickChart
errMsg1 = "The QuickChart final operational screen has appeared but the Dashboard SSO didn't log the user in!%ENTER%%ENTER%"
errMsg2 = "If you have a single sign on (SSO) product in your environment, such as Imprivata OneSign,%ENTER%"
errMsg3 = "or if your browser is enabled to auto log into QuickChart, then %ENTER%"
errMsg4 = "you should check to make sure the correct user has been logged into QuickChart.%ENTER%%ENTER%%ENTER%"
errMsg = StrCat(errMsg1, errMsg2, errMsg3, errMsg4)
Gosub error
endif
hdoc = Browser.document
hLoginForm = hDoc.forms("mainform")
if (hLoginForm == 0) then
errMsg ("QuickChart SSO - Unable to locate the 'mainform' on the QuickChart login screen")
GoTo error
endif
hPracticeField = hLoginForm.elements("practice")
if (hPracticeField == 0) then
errMsg = "Unable to locate the 'practice' field on the QuickChart login screen")
GoTo error
endif
if (%prc2Lnth% <> @FALSE) ; Practice2 parameter passed by dashboard
PracticeInput = strcat("%practice%", " ", "%practtwo%")
else
PracticeInput = practice
endif
hPracticeField.value = PracticeInput
hUserIDField = hLoginForm.elements("username")
if (hUserIDField == 0) then
errMsg = "Unable to locate the 'username' field on the QuickChart login screen")
GoTo error
endif
hUserIDField.value = user
hUserPWDField = hLoginForm.elements("password")
if (hUserPWDField == 0) then
errMsg = "Unable to locate the 'password' field on the QuickChart login screen")
GoTo error
endif
hUserPWDField.value = pass
hUserSubmitButton = hLoginForm.elements("submit")
if (hUserSubmitButton == 0) then
errMsg = "Unable to locate the 'submit' button on the QuickChart login screen")
GoTo error
endif
hUserSubmitButton.click()
timedelay (1)
timer = 0
while !(WinExist(FinalWin)) && !(WinExist(ConfidentialityWin)) && (timer < 20)
timer = timer + 1
if timer == 5 || timer == 10 || timer == 15 || timer == 20
display(1, 'QuickChart SSO - Waiting for Final Window', 'Waiting for the Final QuickChart Window to Appear%Enter%%Enter%Elapsed time is %timer% seconds')
endif
timedelay (1)
BrowserDoc = Browser.Document
BrowserBody = BrowserDoc.Body
BrowserPage = BrowserBody.CreateTextRange
BrowserText = BrowserPage.Text <--- This is working.
if (strIndex(BrowserText, "The practice you entered either doesnt exist or you are not a member of it.", 1, @FWDSCAN) != 0) ;
errMsg1 = " INVALID 'PRACTICE'...%ENTER%%ENTER%%ENTER%"
errMsg2 = "The practice that was entered for you during login to QuickChart was '%PracticeInput%' %ENTER%%ENTER%"
errMsg3 = "However, according to QuickChart, either this practice does not exist, or you are not a member. %ENTER%%ENTER%%ENTER%"
errMsg4 = "Please contact the IT Help Desk at 381-4357, and give them this error information%ENTER%"
errMsg = strcat(errMsg1, errMsg2, errMsg3, errMsg4)
GoSub error
endif
if (strIndex(BrowserText, "You entered an invalid password, please try again", 1, @FWDSCAN) != 0) ;
errMsg1 = " INVALID 'USER ID' OR 'PASSWORD'...%ENTER%%ENTER%%ENTER%"
errMsg2 = "The 'User ID' and/or 'Password' entered for logging into QuickChart %ENTER%"
errMsg3 = "was incorrect. The 'User ID' and 'Password' that were entered were%ENTER%%ENTER%"
errMsg4 = " User ID = '%user%' %ENTER%"
errMsg5 = " Password = '%pass%'%ENTER%%ENTER%"
; errMsg6 = "When you are sure the 'User ID' and 'Password' are correct in Dashboard,%ENTER%"
; errmsg7 = "click the QuickChart button to run this single sign on (SSO) script again. %ENTER%%ENTER%"
errMsg6 = "Please contact the IT Help Desk at 381-4357, and give them this error information. %ENTER%"
; errMsg6 = "REMEMBER - If you ever update your password in QuickChart, don't forget to update the QuickChart password in DashBoard.%ENTER%%ENTER%"
errMsg = strcat(errMsg1, errMsg2, errMsg3, errMsg4, errMsg5, errMsg6)
GoSub error
endif
if (strIndex(BrowserText, "The specified user has been suspended", 1, @FWDSCAN) != 0) ;
errMsg1 = " SUSPENDED QUICKCHART ACCOUNT...%ENTER%%ENTER%%ENTER%"
errMsg2 = "The QuickChart account for 'User ID' = '%user%' has been suspended! %ENTER%%ENTER%"
errMsg3 = "Please contact the IT Help Desk at 381-4357, and give them this error information. %ENTER%"
errMsg = strcat(errMsg1, errMsg2, errMsg3)
GoSub error
endif
if (WinExist(PwExpWin) == @TRUE) ; User's password has expired
; if (WinWaitExist(PwExpWin,3) == @TRUE) ; User's password has expired
errMsg1 = " EXPIRED QUICKCHART PASSWORD...%ENTER%%ENTER%%ENTER%"
errMsg2 = "Your QuickChart password has expired. The 'User ID' and 'Password' that were entered were%ENTER%%ENTER%"
errMsg3 = " User ID = '%user%' %ENTER%"
errMsg4 = " Password = '%pass%'%ENTER%%ENTER%"
errMsg5 = "Please contact the IT Help Desk at 381-4357, and give them this error information. %ENTER%"
errMsg = strcat(errMsg1, errMsg2, errMsg3, errMsg4, errMsg5)
GoSub error
endif
; astatusbar(1,"QuickChart Web Single Sign On","Updating Expired Password...",4,3)
; TimeDelay(1)
; GoSub newpassword
; GoSub updatedashboard
; TimeDelay(3)
endwhile
May not help, but I went over a few of my older scripts. Don't have XP anymore, but they were originally written for it and ran fine. The 2 I tested ran on Win7
instead of
BrowserDoc = Browser.Document
BrowserBody = BrowserDoc.Body
BrowserPage = BrowserBody.CreateTextRange
I would usually code
cText = Browser.Document.Body.CreateTextRange.text
and your version should support the concatenation. Now, assuming it still errors if done like that, I would investigate a timing issue - rather than a timedelay(1) perhaps a loop (or call a udf I put a sample below where oIE is my Browser Object) - just to make sure the page if fully loaded.
#DefineSubroutine ieready()
IntControl(73,1,0,0,0)
t = 0
While oIE.readystate != 4
t = t+1
display(.5,"Loading... Please Be patient... WebSite may be busy...","Attempt %t% on Page %page%")
If t>30 Then Return(0)
EndWhile
t=0
While oIE.Document.readystate != "complete"
t = t+1
display(.5,"Document is...",oIE.Document.readystate)
If t>30 Then Return(0)
EndWhile
Return(1)
#EndSubRoutine
Quote from: elizarrj on November 11, 2014, 05:45:11 AM
I'm sorry if I was not clear in my problem statement.
"I have an issue when trying to execute the following BrowserText = BrowserPage.Text i receive a 1258: Ole UnKnown Name. I have another script that does the exact same thing and it works. What is interesting, I can run the script on a WinXP machine and it works. If I try on a Win 7 machine, I get this error."
Using bold type doesn't change the fact that as written the paragraph has multiple at least plausible interpretations. That said, I can't claim to be the most skilled scribe on the planet either.
Stan does have a
very good suggestion and it is definitely worth trying. I was thinking along those same lines.
I had occasion to run across this problem while working on another issue so I did a bit more testing. In all cases on Windows 7, no matter the site or the security IE settings, I could not get the 'Text' method of the 'range' object returned by the 'CreateTextRange' method to return anything other than VT_NULL. The testing was by no means exhaustive so it would be interesting to here from anyone that can get the method to work on on a fully updated Windows 7 system. More specifically, it would be useful to know the IE security settings and the targeted site.