Question

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

Was it helpful?

Solution

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

OTHER TIPS

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

You can use HttpWebRequest class and POST method.

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.

Depends if the first span with the class value that you don't want it's always found second u could skip it using a flag

var variable = ie.Span(Find.ByClass("TheClass")).Text;
var x = 0;

if(variable != "" && x == 0){

var variable2=variable

}else{
x++
}

that way you only keep the actual thing u want in "variable2" u could adapt the same code to skip the first one and kept the second. instead of skiping the second one and keep the first. sorry for my bad english :c

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top