Reputation: 952
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
Upvotes: 8
Views: 34248
Reputation: 1
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
Upvotes: 0
Reputation: 952
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.
Upvotes: 2
Reputation: 8038
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
Upvotes: 3
Reputation: 22867
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
Upvotes: 3