tags:

views:

1290

answers:

5

I need to register to a site programmatically. I did it with VB6 (using the IE Web Browser component), but I don't know how to edit textboxes on a website using WebBrowser. I don't need to do it with Webbrowser, it's just that I know it can be done with it. I just need to insert a username, a password etc. using my program.

Thanks

+1  A: 

You can use HttpWebRequest class and POST method.

Davorin
+3  A: 

Try having a look at WATin. IT will allow you to automate a browser from C#.

It also has a recorder which can be helpful.

You could use HttpWebRequest but if an open-source component (Watin) is not an issue the task will take a lot less time to achieve.

Kindness,

Dan

Daniel Elliott
+1  A: 

Also have a look at the Watin project: http://www.codeproject.com/KB/aspnet/WatiN.aspx

It's more used for web app testing, but for automating web forms it has great features out of the box.

For a more neutral solution you may also want to check out: http://seleniumhq.org/ Again it's a web app testing framework but it's useful for what you want.

HTH Alex

AlexDuggleby
A: 

Thanks to all, I found how to do it with WebBrowser but WatiN looks better.

    webBrowser1.Navigate("http://www.somewebsite.com/register.php");
    //Wait until website is loaded
    do
    {
        Application.DoEvents();
    }
    while (webBrowser1.IsBusy == true);
    webBrowser1.Document.GetElementById("username"
        ).SetAttribute("value", textBox1.Text);
    //etc.
Proton
ok downloaded a newer version now worx
Proton
A: 

Everyhing looked good until this thing happens: I successfuly got statistics from a website. They are written like <span class="TheClass">Bla bla bla</span> and using this code works var variable = ie.Span(Find.ByClass("TheClass")).Text; I need one more info, but another span uses its class. It's class is "value" Written in Html code as: <span class="value">247</span> (<-- I need this one). But there is another span written <span class="value">2,77445</span> and my program returns 2,77445 when I use that code :S. How to get second span that uses "value" class? Tnx...

Proton