Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2014-12-03
7
93 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 75

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

792 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