View Single Post
  #1 (permalink)  
Old January 20th, 2009, 04:43 AM
adley adley is offline
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using VBScript to Fill Out a Web Form

Peace all, I am currently trying to use VBScript to fill out a web form (and submit it).
For example, I am using this script.

Code:
 
Set IE = CreateObject("InternetExplorer.Application") 
set WshShell = WScript.CreateObject("WScript.Shell")  
IE.Navigate "http://mylogin.page" 
IE.Visible = True 
Wscript.Sleep 6000 
IE.Document.All.Item("fld_userName").Value = "adley" 
IE.Document.All.Item("fld_password").Value = "password" 
WshShell.AppActivate "IE" 
WshShell.SendKeys "{ENTER}"
My problem is this.
The script above works for most pages, but there are a few exceptions that I hoped someone in this forum would help me.
1. If the connection is sooo slow, the "Sleep" line above is not that effective. Does anyone know a better way, such as a "wait until page completely loaded" function?

2. I am using SendKeys above, but for cases where the web page doesn't necessarilly accept ENTER after filling out the password, I need something else. I encounter this for a web page requiring me to select a value from a drop-down box and click the "Log On" button afterward. I can specify the value to be selected, but sending ENTER (or TAB then ENTER) was useless. I don't know how to set a focus to a web object/field using VBScript.

Any help would be much appreciated. Thanks.

Last edited by adley; January 20th, 2009 at 04:48 AM..
Reply With Quote