Yearly Archives: 2007

Capture confirm dialog with WatiN

Tonight, I ran into an issue with with WatiN, an automated browser-based test tool for .net.  Let me first describe my setup… I’m using NUnit 2.4 to drive WatiN.  I could have used NUnitAsp, instead of WatiN, but I like the idea of using an actual browser instance rather than mock objects.  Btw, the NUnit support that Resharper provides is just awesome.  I’m sort of pissed that it took me so long to try it out.  Give resharper a try, if you haven’t yet…

So.. back to the problem that I came across tonight.  Everything was peachy until I needed to interact with a javascript confirmation prompt.  This is the solution that works for me:

ConfirmDialogHandler deleteHandler = new ConfirmDialogHandler();

using (new UseDialogOnce(Browser.DialogWatcher, deleteHandler))

{

    Link deleteLink = Browser.Link(Find.ById(“DeleteLink”));

    Assert.IsTrue(deleteLink.Exists);

    deleteLink.ClickNoWait();

 

    deleteHandler.WaitUntilExists();

    deleteHandler.OKButton.Click();

}

Browser.WaitForComplete();

One thing to note is that Browser just represents the IE object that is created in my TextFixtureSetUp method.  The UseDialogOnce class is:

public class UseDialogOnce : IDisposable

{

    private DialogWatcher dialogWatcher;

    private IDialogHandler dialogHandler;

 

    public UseDialogOnce(DialogWatcher dialogWatcher, IDialogHandler dialogHandler)

    {

        if (dialogWatcher == null)

        {

            throw new ArgumentNullException(“dialogWatcher”);

        }

 

        if (dialogHandler == null)

        {

            throw new ArgumentNullException(“dialogHandler”);

        }

 

        this.dialogWatcher = dialogWatcher;

        this.dialogHandler = dialogHandler;

 

        dialogWatcher.Add(dialogHandler);

    }

 

    public void Dispose()

    {

        Dispose(true);

        GC.SuppressFinalize(this);

        return;

    }

 

    protected virtual void Dispose(bool managedAndNative)

    {

        dialogWatcher.Remove(dialogHandler);

 

        dialogWatcher = null;

        dialogHandler = null;

    }

}

It’s important to note that I use the method ClickNoWait() rather than Click(), for the delete link.  This prevents the situation where WatiN is waiting forever for the click event to finish, while IE just sits with the confirm prompt.

Google gadgets for Property Center

I’ve been playing around with Google gadgets over the last day and a half.  Overall, the experience has been fine.  Writing the actual gadget is basically a mix of html and javascript.  They provide helper methods to grab feeds, xml, or just html content.  To go along with this experiment, I had to write a public api for Property Center.  The api is still very much a work in progress, so I’m not going to officially announce it, as it will likely change in the coming days/weeks.  I’ll mention that I chose not to go the wsdl/asmx route and instead opted to use straight http requests.  I feel this gives the most flexibility to support languages outside of .net.  It also allows me to support REST requests in the future with little modification to the api.

The one thing that I did find is that the google gadget api in IE doesn’t like xml documents with encodings other than utf-8.  In my api code, I was using an XmlWriter object to write to a StringBuilder.  I found out that in this configuration, the xmlwriter will ignore the encoding type, opting always for utf-16.  So… I modified my code slightly to use the response stream instead and things are kosher now.  I believe that it’s a bug with Google Gadgets (not reading encodings other than utf-8) and a bug with Microsoft (not following the specified encoding with XmlWriter and StringBuilder objects).

You can check out the Property Center gadgets by clicking here.
 

Property Center is tenant friendly!

I just completed updating Property Center with a couple new features.  This update most notably allows tenants to request user accounts.  Tenant user accounts allow tenants to log in to your website to add maintenance requests, view their maintenance request history, check their current balance, and view their lease history (including payments/fees). 

By default, Property Center turns on anonymous maintenance requests and tenant user account requests.  As always, Property Center is very configurable and allows you to turn off tenant user account requests and/or anonymous maintenance requests.  So it’s simple to facilitate these additional cases:

  • You can set up Property Center so that tenants have to log in to request maintenance.
  • You can configure Property Center so that tenants cannot log in, but anyone can request maintenance.
  • You can set up Property Center so that tenants cannot request user accounts and anonymous maintenance requests are disabled.

These are all of the changes made with this update:

Additions

  • Tenants can be assigned to user accounts. This allows tenants to
    log in to perform certain tasks not available to anonymous users. You
    can assign roles to these accounts just like any other user account.
    They also have special permissions:

    • They’re able to view lease information and lease transactions only for leases assigned to them.
    • They cannot view other users in the system.
  • Maintenance requests can be requested anonymously or with a tenant user account.
  • Email addresses are validated properly throughout the system.
  • Added additional name templates for generated units (add a new property page)
  • Export as pdf menu item added to the account invoices action menu

Changes

  • Vacant unit counts on the map where changed slightly. Red unit
    counts were hard to see on the orange background, so they were changed
    to black.

Bug Fixes

  • Fixed the vacant unit count color on the property details window
    in the map view. It used to show a green count if there were vacant
    units. Now it correctly shows the count as red.
  • Fixed custom appearance render bug with IE 6

MS releases fix for Vista

This amazes me… 

Microsoft has announced “Windows Vista” was actually a new type of computer virus created by disgruntled employees.  This new type of virus became so popular throughout Microsoft, that was mistakenly put on cds and shipped to customers.  Please be aware that “Windows Vista” is not a Microsoft supported operating system and rather a complex computer virus.  The virus apparently affects RAM usage and general PC performance.  Microsoft has provided a download to fix the problem.  Users with slower connections can contact Microsoft directly to order the cd.

Via MS PressPass 

Nested repeater performance [Resolved]

After failing to receive and answer in the newsgroups and forums, for my nested repeater performance issue, I contacted ScottGu directly.  He didn’t seem sure of what was happening either, so he forwarded the info to a co-worker.  Polita answered:

The repeater calls databind on all its item children in the
ItemDataBound event. So the inner repeater is databound once by the
outer databound, and once by you in your Outer_ItemCreated event
handler. To make the inner repeater bind just once, remove the call to
DataBind in Outer_ItemCreated.

So, it’s not a bug on the asp.net side of things… just in the way fuzzy logic flows through my brain.  Either way, knowing this isn’t a bug and is easily remedied is a nice feeling… Thanks Scott and Polita for clearing this up!
 

xsd.exe fails with statements

I wanted to generate some classes from two related schemas tonight, and unfortunately xsd.exe failed.  It didn’t seem to recognize the <xsd:import> statement in the main xsd file.  Apparently the schemaLocation attribute is considered a hint and is not in the spec.  so… MS doesn’t recognize it.  Anyway, in order to get xsd.exe to work properly, you just have to specify all of the files as parameters. 

So instead of something like

xsd.exe MyParent.xsd /c

I had to use

xsd.exe MyChild.xsd MyParent.xsd /c