Our application has a non-asp.net form tag for the site search box. The
code below for WebForm.cs allows NUnitASP to find the correct form tag.
/// <summary>
/// The HTML tag this tester corresponds to.
/// </summary>
protected HtmlTag Tag
{
get
{
XmlNodeList formNodes =
browser.CurrentPage.GetElementsByTagName("form");
XmlElement formElement = null;
if (formNodes.Count > 1)
{
for (int x = 0; x < formNodes.Count;
x++)
{
if
(formNodes[x].Attributes["id"].Value.StartsWith("_ctl"))
{
formElement =
(XmlElement)formNodes[x];
break;
}
}
Assertion.AssertNotNull("Multiple
<form> tags, none of which look like an ASPNET form.", formElement);
}
else
{
Assertion.AssertEquals("page form
elements", 1, formNodes.Count);
formElement =
(XmlElement)formNodes[0];
}
XmlAttribute id =
formElement.Attributes["id"];
Assertion.AssertNotNull("couldn't find web
form's 'id' attribute", id);
return new HtmlTag(browser, id.Value, this);
}
}
//I assign the copyright to this patch to Brian Knowles and Jim Shore.
|