?
Solved

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

Posted on 2014-12-03
7
Medium Priority
?
102 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
[X]
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
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

765 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