Web automation in VB 2005

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chantymalo
    New Member
    • Feb 2007
    • 8

    Web automation in VB 2005

    I'm trying to create a VB application that will open a web browser on a specific page (http://www.itam.mx/es/servicios/servicios.php), insert the login (Clave Única) and (NIP) password and click the Login button (ENTRAR) on the page, all this automatically.

    I have tried this:

    Dim explorador
    explorador = CreateObject("I nternetExplorer .Application")

    explorador.Navi gate("http://www.itam.mx/es/servicios/servicios.php")
    explorador.Visi ble = True

    explorador.Docu ment.All.Item(" txt_clave").Val ue = ""
    explorador.Docu ment.All.Item(" txt_nip").Value = ""
    explorador.Docu ment.All.Item(" entrar").Click( )


    but it doesn't works at all. And I don´t have any other ideas on how to do this.

    ...thanks.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Did you do it all straight through from start to finish as shown here? Because I believe you need to wait until the Navigation and Document are completed before going ahead.

    Comment

    • chantymalo
      New Member
      • Feb 2007
      • 8

      #3
      I see I would need to wait for the document to be loaded? something like this:

      Dim explorador
      explorador = CreateObject("I nternetExplorer .Application")

      explorador.Navi gate("http://www.itam.mx/es/servicios/servicios.php")
      explorador.Visi ble = True

      explorador.wait (8000) '?????

      explorador.Docu ment.All.Item(" txt_clave").Val ue = ""
      explorador.Docu ment.All.Item(" txt_nip").Value = ""
      explorador.Docu ment.All.Item(" entrar").Click( )

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        I think you'll do better if you exploit the event-driven nature of VB. Rather than trying to go through this is a set sequence as you have shown, you probably should exit this piece of code after executing the Navigate method. Then do the rest in the event procedure triggered when the document is complete.

        I played with this a while back, and I think the event is actually called DocumentComplet e, but I could be wrong.

        If you do want to do it the way you've shown here, I would not recommend waiting for a set length of time, as the time to load a document can vary enormously. You would do better to wait until the status of the control/document changes, or watch for a global flag which is set in the DocumentComplet e event procedure, or something along those lines. In other words, wait until the document is actually completed (or failed?) not for a specific time.

        Comment

        • chantymalo
          New Member
          • Feb 2007
          • 8

          #5
          thanks... I'm going to try something different.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by chantymalo
            thanks... I'm going to try something different.
            Ok. Good luck!

            Comment

            Working...