Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Automation
I am using the Webbrowser control(IE object) in VS 2008 C# Express to automate the
navigation of pages on a partner's web site. The first page contains
an <IFRAME> element:
 
<iframe style='width:40; height:40'; align='center' marginwidth='0'
marginheight='0'
scrolling='no' frameborder='0' id='xyzlogin' name='xyzlogin'
src='https://www.xyzcorp.com/accounts/ServiceLogin'>
</iframe>
 
Within that frame I need to access these three elements:
 
<input type="text" name="Email" value="" class="xyz le val" id="Email"
size="18">
<input type="password" name="Passwd" class="xyz le val" id="Passwd"
size="18">
<input type="submit" name="null" value="Sign in" class="xyz le button"
 
so I to automate programmatically this login: 1)enter the user ID and password, and 2)click
the 'Sign in' button.
 

can someone provide me code sample how to resolve this.
Posted 10-Oct-11 9:54am
Edited 10-Oct-11 10:13am
v5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can try using the below code:
 
ContentPlaceHolder holder = (ContentPlaceHolder)this.CurrentMaster.FindControl("xyzlogin");
 
HtmlControl control1 = (HtmlControl)holder.FindControl("Email");
HtmlControl control2 = (HtmlControl)holder.FindControl("Passwd");
HtmlControl control3 = (HtmlControl)holder.FindControl("Signin");
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

the document object of the webbrowser control has a property called window object, this would give reference to the iframe controls
 
if your webbrowser control name is webBrCtrl then the below line should give you the collections of iFrames in the HTML document that is loaded in the webbrowser control.
 

 
webBrCtrl.Document.Window.Frames
 

hope this solves your problem.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Schatak 394
1 OriginalGriff 330
2 _Amy 115
3 Andreas Gieriet 100
4 Rob Philpott 90
0 OriginalGriff 7,107
1 Sergey Alexandrovich Kryukov 5,623
2 Maciej Los 3,504
3 Peter Leow 3,373
4 DamithSL 2,505


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100