Thursday, February 4, 2010

How to handle ASP.NET Update Panel in WatiN

Handling asp.net update panels with WatiN is a pretty annoying thing.
Click and WaitForLoad usually throws timeout every time.

I have found "just fine" solution that work for me:

static class ElementExtension
{
public static void ActWithToken(this Element Element, Action Action)
{
string Waittoken = "waittoken";
Element.SetAttributeValue(Waittoken, Waittoken);
Action();
Element.WaitUntil(!Find.By(Waittoken, Waittoken));
}

public static void ActWithToken<E>(this E Element, Action<E> Action)
where E : Element
{
string Waittoken = "waittoken";
Element.SetAttributeValue(Waittoken, Waittoken);
Action(Element);
Element.WaitUntil(!Find.By(Waittoken, Waittoken));
}
}


Usage



Page.CreditToLocation.FindItem(1).ActWithToken(e => e.ClickNoWait());

No comments:

Post a Comment