Solved

c# - Open a web page and fill in text press a button

Posted on 2014-12-03
7
87 Views
Last Modified: 2015-07-07
Hi,

How I can use C# to do the following:

1. Open a web page in IE.
2. Put some text in an input field (form).
3. Press a button on this form.

Thanks,

Ward
0
Comment
Question by:whorsfall
7 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 40478455
do you have control over the web page you wish to open ?
for if you don't your looking at a lot of effort to fill in text boxes as you don't know what they are named in someone else's code
0
 

Author Comment

by:whorsfall
ID: 40478463
Hi,

No I don't have contol over the web site. However it is static on our intranet in which the names of the controls stay the same,

Thanks Ward
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 40478470
okay there are a few ways to do this..
the first question is what action will the user use to initiate this

so will the user click a button on your application to execute this ?
and what criteria will be enetered into the textboxes on the page  ?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:whorsfall
ID: 40478492
Hi,

Um I actually my c# app will be a simple winforms app that will generate the text to go into the input field.

Thanks ward
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 40478494
I suggest using WatiN. I believe it was designed with unit testing in mind, but I've used it to automate IE for some of our internal applications. It is even flexible enough to allow you to search for inputs that don't have names or ids, if you so happen to have such.

There is also Selenium Web Driver which does the same thing. I haven't used it myself, but from what I've heard it sounds just a tad more involved to work with than WatiN is.

You can probably get by just using the WebBrowser control in WinForms. I cannot immediately recall how much control you have over the page in WB, but I know that you can execute Javascript against the page, so maybe that would be good enough.
0
 

Author Comment

by:whorsfall
ID: 40482722
Actually I wanted to bring up ie as a seperate app. As opposed having in on the web form and would like to keep it all native c# code.

But is JavaScript the best way Then?

Thanks,
Ward
0
 
LVL 22

Accepted Solution

by:
_TAD_ earned 500 total points
ID: 40844344
Your request is not terribly complex, but there are some nuances that can cause some headaches.

The *easiest* method is to simply create a web browser in C# (lots of examples on the web - cut/paste).  Or if it doesn't have to be visual, just create a web service that creates a web call to the specified page.

once you are pulling the code into a session you can grab the objects via javascript and fill them and then submit the onclick event.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now