Friday 14 August 2009

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 comments:

Oz said...

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?

Anonymous said...

Pretty cool blog you've got here. Thanks for it. I like such topics and everything connected to them. I would like to read a bit more soon.

Kate Hakkinen
escorts in kiev

Anonymous said...

Cool story as for me. It would be great to read more about this matter. The only thing your blog misses is some pictures of some gizmos.

Jeff Kripke
cell phone signal blockers

Anonymous said...

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

Anonymous said...

Rather nice site you've got here. Thanx for it. I like such themes and anything that is connected to them. I definitely want to read a bit more on that blog soon.

Julia Hakkinen
black ebony escorts