[NUnitAsp-devl] Need info about Datagrid cell clicker
Brought to you by:
jlittle82
From: Venkata R. Y. <vr...@sa...> - 2004-10-26 12:41:07
|
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.=20 =20 public void ClickColumn(int columnNumberZeroBased) { XmlElement element =3D GetCellElement(columnNumberZeroBased); XmlNodeList links =3D element.GetElementsByTagName("a"); Assertion.Assert("Attempted to click a cell that doesn't have an anchor (" + HtmlIdAndDescription + ")", links.Count !=3D 0); Assertion.Assert("Expect cell link to have exactly one anchor tag", links.Count =3D=3D 1); =20 XmlElement link =3D (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.=20 =20 =20 /// <summary> /// Tests a row within a data grid. /// </summary> public class Row : AspControlTester { private int rowNumber; private DataGridTester container; =20 /// <summary> /// Create the tester and link it to a row in a specific data grid. /// </summary> /// <param name=3D"rowNumberWhereZeroIsHeader">The row to test.</param> /// <param name=3D"container">The data grid that contains the row.</param> public Row(int rowNumberWhereZeroIsHeader, DataGridTester container) : base(rowNumberWhereZeroIsHeader.ToString(), container) { this.rowNumber =3D rowNumberWhereZeroIsHeader; this.container =3D container; } =20 protected internal override string GetChildElementHtmlId(string inAspId) { return HtmlId + "_" + inAspId; } =20 protected override HtmlTag Tag { get { return container.GetRowTag(rowNumber); } } =20 /// <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 =3D Tag.Children("td"); string[] cellText =3D new string[cells.Length]; for (int i =3D 0; i < cells.Length; i++)=20 { cellText[i] =3D cells[i].BodyNoTags.Trim(); } return cellText; } } =20 ***internal HtmlTag GetCellElement(int columnNumberZeroBased) { HtmlTag[] cells =3D Tag.Children("td"); Assertion.Assert("There is no column #" + columnNumberZeroBased + " in " + HtmlIdAndDescription, columnNumberZeroBased >=3D 0 && columnNumberZeroBased < cells.Length); return cells[columnNumberZeroBased]; } } } =20 Thanks in advance. Waiting for an early reply. =20 Ramana Y.V. |