Releasenotes WatiN 2.0 Final

This page contains the release notes for WatiN, released on February 8, 2011.

You can download this release here or install it via NuGet using: PM> Install-Package WatiN

This release contains binaries for .Net 2.0, 3.5 and 4.0.

General Changes

Next to a bunch of bug fixes, this release adds several new features to WatiN. These are the highlights:

  • Find elements through the use of CSS selectors via the new Find.BySelector(“”) constraint.
  • Added List to support <ul> and <ol> elements and ListItem to support <li> elements.
  • Added support to easily get the children of an element.
  • Added screenshot support for FireFox
  • And at least dialogs popping up in FireFox can now be closed by WatiN

Also a lot of stability improvements have been made when using FireFox or IE8 to run your tests.

And again a big thanks to all who have contributed to this release or are helping to answer questions on StackOverflow and the WatiN mailing lists.

New Find Options

A new method Find.BySelector is added. It accepts any valid jQuery/Sizzle CSS selector string. The following scenarios are supported:

var element = browser.Element(Find.BySelector(…));
var div = browser.Div(Find.BySelector(…));
var elements = browser.Elements.Filter(Find.BySelector(…));
var buttons = browser.Buttons.Filter(Find.BySelector(…));

To support finding elements which have more then one class name set, a new overload has been added:

Find.ByClass(“a_class”, bool_exactMatch).

If bool_exactMatch is true then this will match “a_class b_class”, “aa a_class zz” and “aa a_class”.  Thanks to Frank Schwiet for this contribution.

Fixed a small bug with Find.By. It now accepts a url from which the http part is missing.

New Element

This release adds support for lists (<ul> <ol>) and listitems (<li>)

The <ul> and <ol> elements are both handled by the new List class. Example usage:

var list = browser.List(“myUnorderedListId”);
var lists = browser.Lists;

The <li> element is handled by the new ListItem class. Example usage:

var listitem = browser.ListItem(“li_Id”);
var listitems = browser.ListItems;

Listitems in a List are accessable throught the OwnListItem(constraint) method and OwnListItems property of the List class. These will only return the child list items of the List.

Added support for only getting the child elements of a container element. Following are some usage example but there are many more overloads for the shown methods available:

var button = browser.Div(“divId”).Child(“buttonId”);
var button = browser.Div(“divId”).ChildOfType<button>(“buttonId”));
var button = browser.Div(“divId”).ChildWithTag(“input”, Find.By(“buttonId”), new[] {“text”});

var buttons = browser.Div(“divId”).Children();
var buttons = browser.Div(“divId”).ChildrenOfType<button>();
var buttons = browser.Div(“divId”).ChildrenWithTag(“input”, new[] {“text”});

browser.ElementOfType and browser.ElementsOfType both accept any type inheriting Element. This provides an easy way to (create and) use a customized version of for instance Button. (see ElementOfTypeTests class for examples)

Added possibility to override default WatiN Types. These types need to inherit the default type. Example:


Added inheritance of ElementTagAttribute to CreateElementTagsFromElementTagAttributes. If you want to change behavior of for instance TextField and inherit from the TextField class, there is no need to add all the ElementTagAttributes of TextField to your customized MyTextField anymore.

Browser Changes

Support for CaptureWebPage for FireFox and IE8.
Screenshots: Fixed vertical stitching issue resulting (resulting in gray vertical lines )

Added Browser.SizeWindow(width, height)


Fixed issue where dialogwatcher was not instantiated when a new browser instance was created with and attached to using Browser.AttachTo()

Enabled DialogWatcher for Firefox and DialogWatcher/Window is able to recognize mozilla dialog. This allows DialogWatcher to always close dialogs No dialogs will hang your tests but no support yet for specific dialog handling.

IE8 starts each dialog and htmldialog in a new process and there is no way to relate the new (html)dialog to the IE instance that created the dialog. Because of this closing dialogs created by a specific IE instance is no longer supported.

Added extra style check to the ConfirmDialogHandler. SF Bug 2931464

Added extra style check for FileUploadDialogHandler on windows 7 (SF Bug 2998056)

Fixed LogonDialogHandler but is still not working for IE8.

Fixed issue with BaseDialogHandler.Equals which caused UseDialogOnce to remove all dialoghandlers of same type.

Internet Explorer Specific

Previous versions of WatiN would wait until IE and the DOM document got into the ‘ready’ state. More and more websites never reach this state for instance because of adds constantly loading. WatiN will now wait for IE and the DOM Document to get to the ‘interactive’ or ‘ready’ state to avoid unnecessary time-outs, and to be more responsive.

Restored the use of Settings.SleepTime in IEWaitForComplete.InitialSleep which is called before WatiN checks if a page in IE is fully loaded. Default for SleepTime is 30 milliseconds (tested with IE8 and IE7). On older machines you may experience issues during page load with elements not being found, you should increase this wait time a bit. This setting is not applicable for Firefox.

Reseting the element Id (in IEElement) after fire-ing an event is no longer done in javascript but in code. This fixes an issue when browser settings don’t allow javascript execution (edge case). Fixes SF bug 2944345 “WatiN 2 changes control IDs but not back to original value.”

Added IEFireEventHandler and moved code from IEUtils regarding firing events to this new class. Main reason for this: make use of GetJavaScriptElementReference.

FireFox Specific

Added JSSH xpi for FireFox 3.6. Thanks to James Hollenbeck!

Pinning of an Element (= assigning it to a field in the DOM through javascript) is now done when it matches the (finder) constraint => less firefox chatter with jssh and less variables declared in FireFox pointing to elements.

Improved JavaScript implementation of getting element by Id inside a container element. Now using querySelector() instead of getElementById() if supported by the browser/javascript.

Fixed issue where disabled elements were not recognized in FireFox implementation.

Improvements to FireFoxClientPort.CloseFireFoxProcess (contrib by Jim Evans)

Had to introduce a small wait after fire-ing an event in JSElement.This seems to resolve a lot of missed postbacks (browser busy status not yet set when watin checks) and makes testing on FireFox a lot more stable.

Made it possible to set FireFox.PathToExe so firefox can be started from any location. Can be used when running tests with multiple Firefox versions on one machine.

Page And Control Improvements

Implemented Control.Refresh which calls Element.Refresh. This will force a new search for the element the next time a property or method is accessed on the wrapped Element.

Made Page.Document virtual.

Added (protected) Page.UnverifiedDocument. This allows to access the document but skipping the VerifyDocumentProperties step (and thus not throwing an exception when your not on the right page).


Changed logging to avoid unnecessary retrieval of element attribute values when creating a log message when no LogWriter is set for logging.

All LogWriters now inherit from BaseLogWriter (implementing ILogWriter).

Removed Logger.LogInfo cause this wasn’t used by WatiN but having it in the interface it did suggest so.

Removed setters from interface ILogWriter

Other Changes

Fixed bug: Element.CreateElementFinder now uses NativeElementFinder.CreateNativeElementFinder.


- HtmlDialog.Exists
- HtmlDialog.WaitUntilClosed() and HtmlDialog.WaitUntilClosed(timeout)

Calling browser.Elements[0].WaitUntilRemoved() did throw an exception as soon as the element was removed from the DOM. This is fixed.

Fixed issue where INativeElement.IsElementReferenceStillValid did check for offSetParent existence on Head, Body etc. elements. These elements never have an offSetParent. Checking this resulted in strange behavior in some specific scenarios.

Calling ToString on an Element will now check if Element Exists to prevent timeouts when calling ToString during the creation of an exception message.

Fixed issue where Element.Text would return null for <div></div> in IE and string.empty in FireFox. Both now return null.

Made DomContainer.OnGetNativeDocument protected.

Made TypeTextAction inheritance friendly by exposing the TextField property. Also added (protected) TextField.CreateTypeTextAction to inject your own custom ITypeTextAction from a TextField subclass.

Fixed some documentation issues and added some documentation.

Re-implemented Element.Click (based on contrib by Jim Evans). Moved handling of Click to INativeElement.FireEvent and INativeElement.FireEventNoWait implementations. Fixed issue with FireEventNoWait on FireFox. Due to this INativeElement.ClickOnElement could be removed.

This also effected RadioCheck.Checked setter. Since it calls FireEvent(“onClick”), there is no need to set the checked attribute on the element (was specific for IE). This also resulted in a cleanup in JSElement: no need to ignore setting the checked attribute any more.

Refactored IEFireEventHandler, uses javascript setTimeout to fire the event async (instead of creating a thread).

Fixed specific scenario where nested element reference wasn’t re-found after calling Element.Refresh()

Cleaned up tests regarding differences in (IE6-7) and (Firefox and (IE8 or later)) (thanks to Jim Evans)

Fixed bug with KeyPressNoWait(char) not setting the value in the textfield.

Moved Document.ContainsText(string) implementation to INativeDocumentDocument implementations.

Fix major bug: When different elements with different tags have the same id WatiN might not find the element. Example:

<span id=”myId” /><div id=”myId” />

In this case browser.Div(“myId”).Exists would return false. SF Bug 2921121.

Changed implementation of ElementTag.GetHashCode to prevent Arithmetic Overflow (SF Bug 3000222)

Fixed wrong log message in Browser.BringToFront (SF Bug 3034535)

Fixed issue with NativeElementFinder.FilterImpl causing an exception when calling:

var elements = browser.ElementsOfType<Button>().Filter(Find.ByXXX)