Solved

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

Posted on 2014-12-03
7
96 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…

730 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