Madhan
Madhan

Reputation: 671

Input values to the test box in html using VBscript

I am trying to input / set value to Text box in html using VBscript, In order to automate a small step in my testing process.

I use the below VBscript to achieve the same

Dim objIE
Set objIE = WScript.CreateObject ("InternetExplorer.Application")
Set objShellApp = CreateObject("Shell.Application")
objIE.Width = 700
objIE.Height = 250
objIE.Toolbar = false
objIE.statusbar = false
objIE.Navigate "http://MYURL"
objIE.Visible = true
Set objIE = Nothing 'Set nothing to the object due to trusted policies in IE
For Each objWindow In objShellApp.Windows
If LCase(objWindow.LocationName) = LCase("MSec Test Application 5.9.22") Then
  Set objIE = objWindow
End If
Next
objIE.Document.getElementsByName("whoId").Items(0).value =    "CN45234"                                   'This step not working
objIE.Quit

That Text box element which I tried to set value, has property like the below [I took it using firebug]

<td class="fr"> whoId</td>
<td>
<input class="fr" value="" name="whoId">
</td>

While executing the above VBscript it ends up with error message asenter image description here

I spend lot of time to find solution for this issue, But no luck. Kindly help me to fix it.

Thanks, Madhan

Upvotes: 0

Views: 6379

Answers (1)

Ekkehard.Horner
Ekkehard.Horner

Reputation: 38755

Obey the error message and loose the .Items:

objIE.Document.getElementsByName("whoId")(0).value =    "CN45234"  

(and test your assumptions (valid window found, non empty return of GetElementsByName()))

Upvotes: 2

Related Questions