Solved

VBScript - Internet Explorer 9

Posted on 2014-01-06
11
2,804 Views
Last Modified: 2014-01-16
Good afternoon,

My VBScript which launches an IE window and waits for the value of a button to change no longer works following an upgrade from Internet Explorer 8 to 9 (as part of a move to Windows 7 from Windows XP). After clicking the button the value changes from 'Accept' to 'Submit' and then the VBScript should continue however the value of the button is coming back as BLANK / NULL.

Here is the code snippet -

Set objExplorer = WScript.CreateObject("InternetExplorer.Application", "IE_")
objExplorer.Navigate strURL  
      
Do
      strDecision = objExplorer.Document.Body.All.button.Value
Loop While (strDecision = "Submit")

It worked as expected prior to the upgrade so I assume that the element value is read differently in version 9.

Any help appreciated!

Michael
0
Comment
Question by:Barnardos_2LS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 8

Expert Comment

by:5teveo
ID: 39760494
found this!

http://msdn.microsoft.com/en-us/library/ie/ms537434(v=vs.85).aspx

Hint: all property
[all is no longer supported. Starting with Internet Explorer 11, use getElementById. For info, see Compatibility changes.]
0
 
LVL 1

Author Comment

by:Barnardos_2LS
ID: 39760609
Thanks for the reply but it no longer works in IE9 (we have not moved to IE11).
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 39760828
Try disabling Protected Mode, and / or add your URL to the Trusted Sites list.

Rob.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Barnardos_2LS
ID: 39761547
Unfortunately neither has allowed the button value to be read. I've added a screenshot of the element data below if useful.

Element
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 39761692
Try using the following:
strDecision = objExplorer.Document.getElementByID("button").Value

or you can try other properties, like maybe
strDecision = objExplorer.Document.getElementByID("button").innerText

or
strDecision = objExplorer.Document.getElementByID("button").outerText

Regards,

Rob.
0
 
LVL 1

Author Comment

by:Barnardos_2LS
ID: 39761889
No luck with any of the options unfortunately - all are returned as NULL.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 39767054
OK.  Could you possible provide the source code (or a cut down version) that I could test with here?
0
 
LVL 1

Author Comment

by:Barnardos_2LS
ID: 39767757
Here is the VBS - RunAcceptance.vbs
Here is the web page - test.html

Both are referenced to C:\Temp in the VBS.

Thanks for you help.
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 39769735
Right, I think you'll find that if you run your original by running a command prompt "As Administrator", then running
cscript C:\Scripts\RunAcceptance.vbs

it will work....although I did use:
strDecision = objExplorer.Document.All("button").Value

So, when using a non-admin account, the IE object gets disconnected.  A possible way around that is to loop through the windows after launching the page, and connect to the window found by the window title.

This assumes that the title of the page is the URL you specify, because the TITLE tag isn't set in the HTML.

Regards,

Rob.


'On Error Resume Next

strURL = "http://webserver/test.htm"
Set objExplorer = CreateObject("InternetExplorer.Application")
objExplorer.Navigate strURL  
objExplorer.visible = True
Set objExplorer = Nothing

WScript.Sleep 3000

Set objShellApp = CreateObject("Shell.Application")
For Each objWindow In objShellApp.Windows
	'WScript.Echo objWindow.LocationName
	If LCase(objWindow.LocationName) = LCase(strURL) Then
		Set objExplorer = objWindow
	End If
Next 		

Do 
	'strDecision = objExplorer.Document.getElementByID("isSubmitted").Value
	strDecision = objExplorer.Document.All("button").Value
	wscript.echo strDecision
Loop While (strDecision = "false")

Open in new window

0
 
LVL 1

Author Closing Comment

by:Barnardos_2LS
ID: 39784815
Perfect. Thank you for your help.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 39784885
No problem. Thanks for the grade.
0

Featured Post

Windows running painfully slow? Try these tips..

Stay away from Speed Up Computer Programs that do more harm than good.
Try these tips instead.
Step by step instructions in trouble shooting Windows Performance issues.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mozilla how to book mark to specific book mark folder 10 118
IE11 cannot send an email using a gmail account 2 41
VBA code for SubFolders 11 49
email adress opens in chrome 13 61
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question