RE: [NUnitAsp-devl] Change to handle multiple form tags
Brought to you by:
jlittle82
From: Garrison, J. <JohnGa@DOR.WA.GOV> - 2006-03-23 22:23:19
|
Sorry, that's not quite right. I think it should be if the form action attribute ends with the current page name thusly if (formNodes.Count > 1) { string currentPageName = browser.CurrentUrl.AbsolutePath.Substring(browser.CurrentUrl.AbsolutePath.La stIndexOf('/')+1)); for (int x = 0; x < formNodes.Count; x++) { if (formNodes[x].Attributes["action"].Value.EndsWith(currentPageName) { formElement = (XmlElement)formNodes[x]; break; } } Assertion.AssertNotNull("Multiple <form> tags, none of which look like an ASPNET form.", formElement); } -----Original Message----- From: nun...@li... [mailto:nun...@li...] On Behalf Of Garrison, John Sent: Thursday, March 23, 2006 1:52 PM To: 'nun...@li...' Subject: [NUnitAsp-devl] Change to handle multiple form tags 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. ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ NUnitAsp-devl mailing list NUn...@li... https://lists.sourceforge.net/lists/listinfo/nunitasp-devl |