internal IWebElement GetEducation(string ColumnName, CellPosition cellPosition = CellPosition.VALUE_BASE, string value = "", string Attribute = TagAttributes.Value, bool IsHyperLink = false) { IWebElement cell = null; int ColumnIndex = TableHeader.GetColumnIndex(ColumnName, ColumnIndex = 1); string ColumnCssSelector = "#recordsListTable > tbody > trCHILD > td:nth-child(" + ColumnIndex + ")"; if (IsHyperLink) { ColumnCssSelector = ColumnCssSelector + " > a"; } if (cellPosition.Equals(CellPosition.VALUE_BASE)) { ColumnCssSelector = ColumnCssSelector.Replace("CHILD", ""); ReadOnlyCollection <IWebElement> cells = this.webDriver.FindElements(By.CssSelector(ColumnCssSelector)); foreach (var item in cells) { try { if (item.GetAttribute(Attribute).Trim().ToLower() == value.Trim().ToLower()) { cell = item; break; } } catch { try { if (item.Text.Trim().ToLower() == value.Trim().ToLower()) { cell = item; break; } } catch (Exception ObjException2) { Logger.Error("Error Occured At Column" + ObjException2.Message); } } } } if (cellPosition.Equals(CellPosition.LAST)) { ColumnCssSelector = ColumnCssSelector.Replace("CHILD", ":last-child"); cell = this.webDriver.FindElement(By.CssSelector(ColumnCssSelector)); } if (cellPosition.Equals(CellPosition.FIRST)) { ColumnCssSelector = ColumnCssSelector.Replace("CHILD", ":first-child"); cell = this.webDriver.FindElement(By.CssSelector(ColumnCssSelector)); } return(cell); }
public void CellPositionTest() { // standart constructor var cellPos = new CellPosition(0, 0); Assert.IsNotNull(cellPos); // Constructor CellPosition out of Position var position = new Position(0, 0); cellPos = new CellPosition(position); Assert.IsNotNull(cellPos); // Constructor CellPosition out of PositionI var positionI = new PositionI(0, 0); cellPos = new CellPosition(positionI); Assert.IsNotNull(cellPos); // Tests the == operator var cellPos2 = new CellPosition(0, 0); Assert.True(cellPos == cellPos2); // Tests the Equas function Assert.True(cellPos.Equals(cellPos2)); // Tests the != operator cellPos2 = new CellPosition(1, 1); Assert.True(cellPos != cellPos2); // Tests if its Posible to create a cell position bigger than 31 and smaller then 0 cellPos = new CellPosition(32, 32); Assert.AreNotEqual(32, cellPos.CellX); Assert.AreNotEqual(32, cellPos.CellY); cellPos = new CellPosition(-1, -1); Assert.AreNotEqual(-1, cellPos.CellX); Assert.AreNotEqual(-1, cellPos.CellY); }