[NUnitAsp-devl] RE: Need info about Datagrid cell clicker
Brought to you by:
jlittle82
From: Peter J. <pj...@ne...> - 2004-10-28 02:02:28
|
Dear Ramana, When I upgraded to NUnitASP 1.5, I found the same breakages in my previously posted code. I just posted my refactored patches to the SourceForge site, so feel free to take a look and see if it helps you. <http://sourceforge.net/tracker/index.php?func=detail&aid=1055819&group_id=4 9940&atid=458032> http://sourceforge.net/tracker/index.php?func=detail&aid=1055819&group_id=49 940&atid=458032 Pete _____ From: Venkata Ramana Yekasi [mailto:vr...@sa...] Sent: Tuesday, October 26, 2004 8:41 AM To: pj...@us...; nun...@li... Subject: Need info about Datagrid cell clicker Hi I am using NUnitAsp (latest with multiform support) in my project and got lost mainly at clicking of cell in datagrid. I downloaded your code for datagrid cell cliking event. Which is below. public void ClickColumn(int columnNumberZeroBased) { XmlElement element = GetCellElement(columnNumberZeroBased); XmlNodeList links = element.GetElementsByTagName("a"); Assertion.Assert("Attempted to click a cell that doesn't have an anchor (" + HtmlIdAndDescription + ")", links.Count != 0); Assertion.Assert("Expect cell link to have exactly one anchor tag", links.Count == 1); XmlElement link = (XmlElement)links[0]; PostBack(link.GetAttribute("href")); } If I paste this code in below Row it throws error. As GetCellElement(int columnNumberZeroBased) returns HtmlTag and not XmlElement. Can you please look into this issue. /// <summary> /// Tests a row within a data grid. /// </summary> public class Row : AspControlTester { private int rowNumber; private DataGridTester container; /// <summary> /// Create the tester and link it to a row in a specific data grid. /// </summary> /// <param name="rowNumberWhereZeroIsHeader">The row to test.</param> /// <param name="container">The data grid that contains the row.</param> public Row(int rowNumberWhereZeroIsHeader, DataGridTester container) : base(rowNumberWhereZeroIsHeader.ToString(), container) { this.rowNumber = rowNumberWhereZeroIsHeader; this.container = container; } protected internal override string GetChildElementHtmlId(string inAspId) { return HtmlId + "_" + inAspId; } protected override HtmlTag Tag { get { return container.GetRowTag(rowNumber); } } /// <summary> /// The cells in the row. Whitespace has been trimmed from the front and back /// of the cells. /// </summary> public string[] TrimmedCells { get { HtmlTag[] cells = Tag.Children("td"); string[] cellText = new string[cells.Length]; for (int i = 0; i < cells.Length; i++) { cellText[i] = cells[i].BodyNoTags.Trim(); } return cellText; } } ***internal HtmlTag GetCellElement(int columnNumberZeroBased) { HtmlTag[] cells = Tag.Children("td"); Assertion.Assert("There is no column #" + columnNumberZeroBased + " in " + HtmlIdAndDescription, columnNumberZeroBased >= 0 && columnNumberZeroBased < cells.Length); return cells[columnNumberZeroBased]; } } } Thanks in advance. Waiting for an early reply. Ramana Y.V. |