Releasenotes WatiN 1.1.0.4000

This page contains the release notes for WatiN 1.1.0.4000, released on 2 May 2007.

You can download this release here.


Changes in general

Added FileDownloadHandler
Added support for handling file download and the Save As dialog. Following is an example on how to use this new handler. Thanks to Daaron Dwyer for the initial implementation!

using(IE ie = new IE(someUrlToGoTo))
{
 FileDownloadHandler fileDownloadHandler = new FileDownloadHandler(fullFileName);
 ie.AddDialogHandler(fileDownloadHandler);

 ie.Link("startDownloadLinkId").Click();

 fileDownloadHandler.WaitUntilFileDownloadDialogIsHandled(15);
 fileDownloadHandler.WaitUntilDownloadCompleted(200);
}


Improved AJAX support
To better support testing of AJAX enabled websites, this release adds some more options to your toolbox.

A new method is added that will wait until some attribute has a certain value. This might be handy in situations where you need to wait until a value of an element gets updated.

Element.WaitUntil(Attribute, timeout) has four overloads accepting an attributename, expectedvalue (string/Regex) and a timeout. Following are some examples on how to use this new feature:

// Wait until some textfield is enabled
textfield.WaitUntil("disable", false.ToSting, 10);
// Wait until some textfield is visible and enabled
textfield.WaitUntil(new Attribute("visibile", new BoolComparer(true)) && new Attribute("disabled", new BoolComparer(false)));


A Refresh method is also added. Calling this method will clear the cached reference to the wrapped html element (caching is done to speed up performance when calling multiple properties and methods on the same element). So when the next time a property or method of the element is called, WatiN will first retrieve a fresh reference to the html element. Using this Refresh method can be handy in some postback scenario's.


SelectList select = ie.SelectList(id);

// Lets assume calling Select causes a postback,
// which would invalidate the reference to the html selectlist.
select.Select(val);

// Refresh will clear the cached reference to the html selectlist.
select.Refresh();

// Assert against a freshly fetched reference to the html selectlist.
Assert.AreEqual(val, select.SelectedItem);

A third change to better support testing of AJAX websites has been made to the way elements are retrieved from the webpage. Due to this improvement two problems have been solved:

  • Calling Exists on an element within an element that doesn't (jet) exist is now supported, adding even more support for AJAX scenarios in which a hierarchy of html elements is added to a page by some javascript. Example: Assert.IsFalse(ie.Div("doesNotExistJet").TextField("textField1").Exists);
  • If a page redirect has happend, WatiN no longer keeps searching in the html element collection of the old page. A fresh element collection is fetched (from the currently displayed page) every time WatiN is searching for an element on a page or when your code calls one of the Element.WaitUntil... methods. Thanks to Francis Vaundry for supplying some unit tests and html files.

The last change regarding AJAX support has been made to the WaitUntil... methods. These methods now ignore exceptions during the wait, making it less vulnerable for UnauthorisedExceptions thrown by the DOM if an element is in the DOM but not ready to by accessed. During the Wait time this should be ignored. The TimeoutException's innerexception is set if an element could not be found due to an exception throw during the last search cycle in the WaitUntil method.


Added support for the not operator
When searching for an element or a collection of elements you might want to filter on elements which don't have an attribute with some value. Like returning all buttons which haven't set there class name to some value.

The following code waits until the url of the image is not equal to a certain value: // using the ! overload on Attribute class
ie.Image("image1").WaitUntil(!Find.BySrc("http://website/firstimage.jpg"));

// using the Not class
ie.Image("image1").WaitUntil(new Not(Find.BySrc("http://website/firstimage.jpg")));

Finding an IE instance by its window handle
Added support for finding an Internet Explorer instance by it window handle (hwnd).

IE ie = IE.AttachToIE(Find.ByCustom("hwnd", windowHandle));
bool ieExist = IE.Exists(Find.ByCustom("hwnd",windowHandle))


Run a JScript
A RunScript method has been added to the IE object. This makes it easier to run a JScript inside the browser. Thanks to Daaron Dwyer for the initial implementation!

ie.RunScript(yourJScriptOrVBScriptGoesHere);


Improved eventhandler detection
Changed the way WatiN determines if an eventhandler is attached to an event of an element. Previous versions of WatiN parsed the HTML of the element. When eventhandlers where attached by some java code not part of the innerhtml of the element, WatiN decided no eventhandlers were registered. WatiN now looks at the DOM properties for these events which solves this problem. This fix is most noticable when using TextField.TypeText() where WatiN fires onkeydown and onkeyup events if eventhandlers are attached.


Renamed ShowFrames to DumpFrames
Renamed ShowFrames to DumpFrames. All Dump* methods now have an overload which accepts an object implementing ILogWriter. This makes it possible to log the dump to something else then the debug window.


Improved stability of DialogHandler
Added try/catch around the call to IDialogHandler.HandleDialog method implemented by dialogHandlers. If an exception occurs during this call it will be catched, logged through Logger.LogAction and stored in lastException property of the DialogWatcher. This makes it possible to test for exceptions throw by dialoghandlers. Excpetions thrown by dialoghandlers will no longer interrupt the working of DialogWatcher.


Added a BaseComparer class
Added a BaseComparer class. It is abstract, implements ICompare and makes the Compare method virtual.


API Changes

See this page for a full list of all the API changes between version 1.0.0.4000 and 1.1.0.4000


SourceForge Trackers

Added Feature requests:

1582780 Add support for filedownload
1670210 Add greater support for javascript calls
1678512 Add Element.WaitUntil(attributename, expectedvalue, timeout)
1708830 IE.AttachToIE(Find.ByHandle(....


Fixed Bugs:

1672606 LogonDialogHandler throws exception if pwd = blank
1681737 WaitUntilExists doesn't ignore exceptions during the wait.
1681742 Find.ByIndex doesn't seem to work with input elements
1684003 WaitUntilExist timesout if a redirect occurs during wait.
xxxxxxx ContainsText should return false if Document.body is null.