Interacting with the web using WebRobot v1.0

Uploading files to YouSendIt

We will now make things a bit more complicated for ourselves, by uploading files to YouSendIt. This site allows you to share files by uploading them to a central server, and then warning the recipient of the share that they have a file ready to download.

This page uses JavaScript extensively to modify the content that is presented to the user, and also the fields and actions contained inside the forms, so it will not be as straightforward to use. We will parse the page, and upload a file to a multipart form on this site.

First, we will create a Windows Forms Project. Then, we will d ouble-click on the main form. You should see an empty Load handler:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load

End Sub


Next, we will add a reference to the WebRobot component:



Write the following code on the Load handler:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim wrobot As New foxtrot.xray.WebRobot
    wrobot.Base = "http://www.yousendit.com/"
    wrobot.LoadPage("/")
   
'getting file upload form from page
    Dim wform As foxtrot.xray.Form = wrobot.GetFormByName("tform")
   
'displaying the amount of fields on the form
    MessageBox.Show("The form contains " & wform.FieldCount & " fields")
End Sub

Our upload form arrives with zero fields, since the YouSendIt page populates the form dynamically, using JavaScript. For this particular case, we must add the form input fields by hand.


You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“If debugging is the process of removing software bugs, then programming must be the process of putting them in.” - Edsger Dijkstra