If you are automating web pages or web applications you may at some point need to automate dialog boxes produced by client side script, like the one that pops up when you click the link below:
So you might want to be aware that the title of these popups varies between different versions of Internet Explorer. In IE6 it was “Microsoft Internet Explorer”. In IE7 it is “Windows Internet Explorer” and in IE8 it is now “Message from webpage”.
I much prefer the last one from an automation point of view since it differs significantly from the title of the main IE window which usually contains the phrase “Microsoft Internet Explorer” in IE7 and “Windows Internet Explorer” in IE8.
So if we wanted to click on the Yes button if we were writing a script for IE8 we could use the following code:
SetFocus>Message from webpage Press Enter
But what if we didn’t know what version of IE our script would be automating? If you were giving your script to someone else or putting it on some other PC you may not know what version of IE was being used. What we need to do is make the script find out what version of IE is installed on the computer.
Here’s how to make the script determine which version of IE is in use:
RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Internet Explorer,Version,IEver Separate>IEVER,.,bits Let>IEVER=bits_1
IEVER now contains the major version number of Internet Explorer.
So we could now use this to define the title we expect from the dialog box and confirm it:
RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Internet Explorer,Version,IEver Separate>IEVER,.,bits Let>IEVER=bits_1 Let>dialogTitle_IE6=Microsoft Internet Explorer Let>dialogTitle_IE7=Windows Internet Explorer Let>dialogTitle_IE8=Message from webpage SetFocus>dialogTitle_IE%IEVER% Press Enter
Of course this is all assuming you’re using the English version of Internet Explorer. I cannot vouch for other languages.