4

I found this script online, I edited most of it.

It is able to enter username, and password on its down but it is not able to click login.

please help me fix Here is login forum.

http://desistream.tv/en/index.shtml

Here is Script currently it is in IE but I will need to change it open in Google Chrome.

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 = "myusername"
    .getElementByID("login_password").value = "mypassword"
    .getElementByID("form").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

2 Answers 2

3

Here is...

Call 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("username").value = "myusername"
        .getElementByID("pass").value = "mypassword"
        .getElementsByName("frmLogin")(0).Submit
    End With
End Function

Sub Wait(IE)
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy
End Sub
3
  • Thanks, how can I add condition if account is already logged in? because it is prompting error.
    – Mowgli
    Jan 8, 2013 at 19:34
  • 1
    Glad to see that I not forget everything as my last web scripting was about 10 years ago :) The site rules not allow multiple questions in one topic, so you can open new topic if you like, and probably will get better reply, but my short reply is - just find an html element that's available on that page only when you logged-in and check for existence of that element, and to start login only if needs. Jan 8, 2013 at 20:17
  • As for doing so in Google Chrome, you can't without automation extensions. See this thread link, or just google for "google chrome browser automation". Jan 8, 2013 at 20:18
1

If you look at the page source, you'll see that the actual <form> tag is called frmLogin, not login.

2
  • Thanks alot, I looked at div id forum, not form name, Thanks alot.
    – Mowgli
    Jan 8, 2013 at 18:49
  • I have question, how can I make it not prompt error, if account is already logged in ? Thanks
    – Mowgli
    Jan 8, 2013 at 18:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.