Thursday, February 28, 2008

WebAii 1.1 and Verification Patterns

Given that we are approaching V1.1 release, we wanted to give a quick preview of what to expect in V1.1. V1.1 is going to be all about bug fixes and performance enhancements in addition to few small feature sets that we think will make writing automated web tests a bit simpler. Mostly around writing verifications. Oh, V1.1 will also be natively compiled against .NET 3.5 and plugs in VS2008.

Performance: We have enhancements that span the entire framework. All our threading is now pooled to enhance machine resource utilization. We also have optimized both the Find logic and DomRefresh algorithms.

Verification: Anyone who has written automated tests knows that an automated test is only as good as its verification. Many current automated test frameworks brag about their ability to automate tests and perform actions but give very little focus to verification, us included :). BUT we have recognized that and in V1.1 we are taking steps to build facilities to enhance verification.

Let's take a look at what we have started building in V1.1:

Take for example a select drop down element on a page. Let's first assume you want to validate that a certain attribute exists on the element. In WebAii 1.0 you might have code that looks like this:




// Get my select drop down

HtmlSelect select = Find.ById<HtmlSelect>("myDropDown");



// Assert that it contains an attribute 'attr'

Assert.IsTrue(string.IsNullOrEmpty(

select.BaseElement.GetAttributeValueOrEmpty(
"attr")),

string.Format("Attribut does '{0}' not exist", "attr"));






Wouldn't be better if I can do:

// Assert an attribute exists

select.AssertAttribute().Exists("attr");



Now, we're talking... Much nicer... It is:

  1. Less code to write.
  2. By just glancing at this piece of code I know that the intent is to validate an attribute hence "AssertAttribute"
  3. I don't have to worry about putting in the expected/actual since the assert itself is specialized and will automatically include that information in the assert exception.

In V1.1, we have provided three rich assert classes that are extensions (using C# 3.0 extension methods) to the HtmlControl base class so that all the HtmlControls will get them.


Here are some examples:

// Verify a style

select.AssertStyle().Font(HtmlStyleFont.Family, "Tahoma", HtmlStyleType.Computed);



// Verify context

select.AssertContent().TextContent(StringCompareType.NotContain, "foo");


There are also specialized Asserts on HtmlSelect and HtmlTable that do specialized table and select validations for example:


// Select: Validate the selected index

select.AssertSelect().SelectedIndex(NumberCompareType.GreaterThan, 3);


Or...


// Table : Validate column count

table.AssertTable().ColumnCount(NumberCompareType.LessThanOrEqual, 3);


The other cool aspect of this is that we have built an extensible framework for asserts that you can use to extend some of these existing asserts or build your own asserts for your custom controls. We will dedicate another post to go over that.

3 comments:

Anonymous said...

Nice work on the 1.0 release. Looking forward to 1.1. Keep up the good work!

Anonymous said...

Any word on timeframe? :)

ArtOfTest, Inc. said...

1.1 RC0 is already posted on our download page. Please check our website www.artoftest.com