Created
February 18, 2013 17:51
-
-
Save BrockFredin/4979223 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using OpenQA.Selenium; | |
| using OpenQA; | |
| using Selenium.Controllers; | |
| namespace Selenium.Controllers | |
| { | |
| public class Table : BaseObject | |
| { | |
| private int rowCount; | |
| private int columnCount; | |
| public Table(IWebElement objectName) | |
| : base(objectName) | |
| { | |
| this.objectName = objectName; | |
| } | |
| public string RowCount | |
| { | |
| get | |
| { | |
| return GetRowCount; | |
| } | |
| } | |
| public IWebElement GetTable() | |
| { | |
| return objectName; | |
| } | |
| public void set_Table() | |
| { | |
| this.objectName = objectName; | |
| } | |
| public string GetRowCount(IWebElement element) | |
| { | |
| IList<IWebElement> rowCount = element.FindElements(By.CssSelector("tr")); | |
| return rowCount.Count().ToString(); | |
| } | |
| public int ColumnCount(IWebElement element) | |
| { | |
| IList<IWebElement> tableRows = element.FindElements(By.CssSelector("tr")); | |
| IWebElement headerRow = tableRows[0]; | |
| IList<IWebElement> tableCols = headerRow.FindElements(By.CssSelector("td")); | |
| return tableCols.Count(); | |
| } | |
| public IWebElement GetCell(int rowIdx, int colIdx, int editorIdx) | |
| { | |
| try | |
| { | |
| IList<IWebElement> tableRows = objectName.FindElements(By.CssSelector("tr")); | |
| IWebElement currentRow = tableRows[rowIdx - 1]; | |
| IList<IWebElement> tableCols = currentRow.FindElements(By.CssSelector("td")); | |
| IWebElement cell = tableCols[colIdx - 1]; | |
| IWebElement cellEditor = cell.FindElements(By.TagName("input"))[editorIdx]; | |
| return cellEditor; | |
| } | |
| catch (NoSuchElementException exception) | |
| { | |
| throw new NoSuchElementException("Failed to get cell"); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment