Results 1 to 6 of 6

Thread: Webpage form input automation

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    4

    Webpage form input automation

    hello everyone first timer here.

    I have a list of data which needs to be inputted into many different fields on a webpage. usually about 1000 or so and i am trying to automate this using vb.net but i couldn't find a better solution than using appactivate and sendkeys. this solution definitely isn't very accurate and reliable.

    is there another, better way of accomplishing this?

    is there a way to find certain input fields on a webpage, set focus to it and input data in a more reliable way?

    the way i have it written at the moment is appactivate and tab to certain fields and input data using sendkeys.

    thanks for any input guys.

  2. #2
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Re: Webpage form input automation

    Yep:

    vb Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         WebBrowser1.Navigate(New Uri("http://google.com"))
    3.     End Sub
    4.  
    5.     Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    6.         WebBrowser1.Document.GetElementById("lst-ib").InnerText = "asd"
    7.     End Sub

    Hope this helps
    Kris

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    4

    Re: Webpage form input automation

    Oh, wow! Awesome. I definitely see the way now. Thank you so much.

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    4

    Re: Webpage form input automation

    Ok, i've run into a bit of trouble and I can't seem to figure out why this is happening.

    I've tested your code the way it was loading up google.com and it worked flawlessly.

    and i tried it on the webpage i need to have data filled out in, it seems to work but some fields it's just not working.

    error i'm getting is "Object reference is not set to an instance of an object."

    the html code
    Code:
    <input type="text" name="new_hawb_number" value="" maxlength="12" size="15" onBlur='javascript:inputCheck();' style="border: 1px solid #D1D1D1" class="Txt" />
    so the page completely load and I add this to a button's click event to see how it works.

    vb Code:
    1. WebBrowser1.Document.GetElementById("new_hawb_number").InnerText = "123456"

    are there special instances where this method just doesn't work?

    this seems to work everywhere except the form page that i actually need to have data inputted.

    Thanks for any inputs!

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Webpage form input automation

    That error means that you are calling a method on Nothing. Since Nothing has no methods, you get the error. Solving it usually involves first figuring out which object is Nothing. In this case, there appears to be a clear candidate:

    WebBrowser1.Document.GetElementById("new_hawb_number")

    If that ID isn't found, then GetElementByID will return Nothing. You would then be trying to call .InnerText on Nothing, hence the error. The alternatives would be WebBrowser1 or WebBrowser1.Document, but if this is working for some elements, then neither of those two is Nothing. Therefore, I would say that you have the wrong ID for that element.
    My usual boring signature: Nothing

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    4

    Re: Webpage form input automation

    i think i may have found the problem.

    this site uses iframes and after scouring the net it seems a lot of people are having this same issue.

    hopefully i'll figure this out but pulling my hair out atm ^^.

    will update if i do.

    thanks everyone.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width