Mowgli
Mowgli

Reputation: 3512

IE 9 error getElementbyId: Object required

for some reason, VBS below works like a charm in IE 8, but in IE9 on both of my Laptops I get Object Required at .getElement.

How can I fix this please.

WScript.Quit Main

Function Main
  Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
  IE.Visible = True
  IE.Navigate "http://desistream.tv/en/index.shtml"
  Wait IE
  With IE.Document
    .getElementByID("login_username").value = "myuser"
    .getElementByID("login_password").value = "mypass"
    .getElementByID("frmLogin").submit
  End With
End Function

Sub Wait(IE)
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy 
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy 
End Sub

Sub IE_OnQuit
  On Error Resume Next
  WScript.StdErr.WriteLine "IE closed before script finished."
  WScript.Quit
End Sub

edit

this is what I got so far in JScript

var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.Run("Chrome www.desistream.tv", 10, true);
WScript.Sleep(500); 

Upvotes: 1

Views: 3087

Answers (1)

Fionnuala
Fionnuala

Reputation: 91306

You need to use the right names. The names you have given are the Name property, not the ID, so:

.getElementByID("login_username").value = "myuser"
.getElementByID("login_password").value = "mypass"

Should be:

.getElementByID("username").Value = "myuser"
.getElementByID("pass").Value = "mypass"

Upvotes: 1

Related Questions