My Answer(s) posted on Code Project web site Part-2

Question : How to maximize window
Hi I’m using WatiN testing tool, I have problem in maximinzing the windowi used the following codeie.ShowWindow(NativeMethod.ShowWindowStyle.Maximize)but i’m getting error: “NativeMethod does not exist in the current context “and the window is not maximized.plz help me with this..
thanking you
Jawed: Hi Friend , please use the below code to maximizg the IE window.
ie.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
Thanks.

Question: How to handle javascript popup’s
Hi I’ve scenario where i need to create users and upon successfully creating a user i get a popup with Successfully created msg and contains a “OK” button i need to click on the popup to continue further how to handle these kind of popups and also how to downlaod a file and save it. please suggest some solution.
Jawed: For Succesfully created msg popup you can use below code(if it is ALERT)
//Add this namespace for dialogHandlers
using WatiN.Core.DialogHandlers;

AlertDialogHandler alertDialogHandler = new AlertDialogHandler();
ie.DialogWatcher.Add(alertDialogHandler );
alertDialogHandler.WaitUntilExists();
alertDialogHandler.OKButton.Click();
ie.WaitForComplete();
ie.DialogWatcher.RemoveAll(alertDialogHandler);
Hope it would be usefull for you.Thanks!!

Question: Use WatiN to fill form fields in a running IE instance
Hi,Is it possible to use WatiN to interact with a running instance of IE. I’m looking for a toolset that makes it easy to fill fields (such as textboxes, comboboxes, checkboxes) in a webpage (that’s part of a portal solution).Does WatiN also allow to select submenu-items on a page ? Thanx Filip!
Jawed: Hi , WATiN can perform an action similar to a tester or user is performing on any application.the action perform by WATiN tool is called as Automation yeah WATIN can allow you to select submenu-items on an application page.after writing few lines of code in WATIN using C# it can fill the required input fields like(textboxes,select combo- boxes,checked/unchecked checkbox,radio button,click on link etc etc).
please refer the below link for more information
http://watin.sourceforge.net/gettingstarted.html
Happy Automation.

Question: Re:Use WatiN to fill form fields in a running IE instance
Thanks Jawed !
But can I also hook WatiN into a running instance of IE, or not ?
Or in other words, what does the following line of code do when an other IE window is already opened?
// Open Internet Explorer window and
// goto the portal webapp
IE ie = new IE(http://www.e-notariaat.be);
Does it add another TAB or does it open a separate IE window (with seperate logon credentials) ?
In Delphi, I could do automation on a running OR new instance of e.g.
Word : try MSWord := GetActiveOleObject(‘Word.Application’);
except MSWord := CreateOleObject(‘Word.Application’);
end;
The problem I see (although I’m not sure) is that the website I wish to target, is a portal that requires a SmartCard-based login (+manual pin-code), and as most users have already logged in to this portal in their running IE session, I wish to hook in there too …I haven’t tried any of this, but I try to foresee how and if this would work in a typical use case of my customers…
Jawed: Thanks Filip!!Please find below my answers related to your queries.
Filip: But can I also hook WatiN into a running instance of IE, or not ?
jawed: yes you can!!!just a simple Watin code can hook the running instance of IE
IE ie = IE.AttachToIE(Find.ByUrl(url));
the above line of would take the control of already running instance of IE searching by URL.
Filip: what does the following line of code do when an other IE window is already opened?
// Open Internet Explorer window and
// goto the portal webapp
IE ie = new IE(http://www.e-notariaat.be/);
Does it add another TAB or does it open a separate IE window (with seperate logon credentials) ?
Jawed:The above line of code will open a new instance of IE browser.
Filip: The problem I see (although I’m not sure) is that the website I wish to target, is a portal thatrequires a SmartCard-based login (+manual pin-code), and as most users have already logged in tothis portal in their running IE session, I wish to hook in there too …
Jawed: For this approach you can apply method like : Find the already running instance of IE by URL/Value/title etc and take the control of that running IE instance.for that you can use below line of code
IE ie = IE.AttachToIE(Find.ByUrl(“”) Find.ByClass(“”) Find.ById(“”) Find.ByName(“”) Find.ByTitle(“”) Find.ByValue(“”));
Please let me know for any question/concern
Continue..
Filip: Hi Jawed,
Thanks for the answers ! Now, I am convinced that WatiN will let me do the stuff I would like to accomplish. Right now, I am enjoying a weekend in the Ardennes (in the south of Belgium) with my wife and kids, but I will give WatiN a good spin real soon.
Thanks again.
Filip

5 thoughts on “My Answer(s) posted on Code Project web site Part-2

  1. Hi,

    I need to open a new IE tab using watin. Is that possible?

    Firefox can be opened in a separate tab using Firefox.openInNewTab(string url)

    Is there a similar behavior for IE?

  2. Rather nice site you've got here. Thanks the author for it. I like such topics and anything connected to this matter. I definitely want to read a bit more soon.
    Don't you think design should be changed from time to time?

    Anete Hakkinen
    escort monaco

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s