473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

populating fields in webBrowser

M R
i am writing an application (C#) that automates the process of loading a web
page, login into a site and then simulates the navigation of the site.
the program uses a winform with a webBrowser control that is used to load
the web page. i am able to successfully navigate the site but am having
trouble entering data into the fields. the two fields are the username and
password. i would like to automatically enter the username and password into
the fields and then click the login button,.
the question is how to i programmatically access the controls on this
page in the webBrowser control and then click on the button?
thanks for any tips and hints
MR
Jun 21 '07 #1
2 8549
On 21 Jun, 07:20, "M R" <moshe.r...@zoomix.comwrote:
i am writing an application (C#) that automates the process of loading a web
page, login into a site and then simulates the navigation of the site.
the program uses a winform with a webBrowser control that is used to load
the web page. i am able to successfully navigate the site but am having
trouble entering data into the fields. the two fields are the username and
password. i would like to automatically enter the username and password into
the fields and then click the login button,.
the question is how to i programmatically access the controls on this
page in the webBrowser control and then click on the button?
thanks for any tips and hints
MR
Try something like this:

/*Assuming the following HTML in document
*
* <form>
* <input type="text" name="username" />
* <input type="password" name="password" />
* <input type="submit" name="login" value="Log In" />
* </form>
*/

mshtml.IHTMLDocument2 doc = axWebBrowser1.Document as
mshtml.IHTMLDocument2;

mshtml.HTMLInputElement otxtUserNameBox = (mshtml.HTMLInputElement)
doc.all.item("username", 0);
otxtUserNameBox.value = "test_uname";

mshtml.HTMLInputElement otxtPassWordBox = (mshtml.HTMLInputElement)
doc.all.item("password", 0);
otxtPassWordBox.value = "test_pword";

mshtml.HTMLInputElement btnLogin = (mshtml.HTMLInputElement)
doc.all.item("login", 0);
btnLogin.click();

Jun 21 '07 #2
MR,

You can use the Document property of the WebBrowser control to gain
access to the HTML DOM (this was pointed out already).

However, I would ask why not use the HttpWebRequest/HttpWebResponse
classes? A visual component isn't necessary for automating the process, as
you seem to have all the information you need. You could download the
content, parse it, and then send new requests based on that content.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"M R" <mo********@zoomix.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>i am writing an application (C#) that automates the process of loading a
web
page, login into a site and then simulates the navigation of the site.
the program uses a winform with a webBrowser control that is used to load
the web page. i am able to successfully navigate the site but am having
trouble entering data into the fields. the two fields are the username and
password. i would like to automatically enter the username and password
into
the fields and then click the login button,.
the question is how to i programmatically access the controls on this
page in the webBrowser control and then click on the button?
thanks for any tips and hints
MR


Jun 21 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
1
by: cloverme | last post by:
Hi, I need help populating a listbox from a database on a webform. I created a an access database with a table, fields and data. Then I created a WebForm in vb.net and added a DropDownList...
4
by: Lumpierbritches | last post by:
Thank you once again for any and all assistance. I'm building an application that's getting quite bulky due to the number of forms, macros and procedures. I was wondering if there's a way to use 1...
6
by: =?Utf-8?B?U2FtZWVrc2hh?= | last post by:
Hi, I want to write a simple .net program to open a URL, fill in fields, and click on a button to submit it using .net 1.1 framework. Can someone help in suggesting the libraries I should use?...
13
by: Mary | last post by:
I'll pulling my hair out on this one and would be so appreciative of any help. I am creating a data entry form to enter results of a student survey. There are 40 questions on the survey. The...
0
by: MR | last post by:
i am writing an application that automates the process of loading a web page, login into a site and then simulates the navigation of the site. the program uses a winform with a webBrowser control...
27
by: wideasleep | last post by:
Hello, I have a form that has a combo box that populates other fields. This works great but it doesn't save that information in the table where those fields are coming from. The only one that's...
4
by: prosad | last post by:
hello, Just solved a problem using Javascript onclick, can click on any cell in a dynamic table and it will pass the innerText object value to my form text field. parts of code given below: ...
3
by: phonzie | last post by:
First off, I'm using C# A WebBrowser Control This is all inside the webbrowser I'm trying to fill a text field with a variable (The variable works fine, everything checks out, but the text...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.