public string GetCellText(int rowNumber, int colNumber) { var rows = Element.FindElements(By.CssSelector("tr.grid-row")); if (rows.Count == 0) { Assert.Fail("Table has 0 rows"); } if (rowNumber >= rows.Count) { Assert.Fail("Table only has " + rows.Count + " rows"); } var cells = rows[rowNumber].FindElements(By.CssSelector("td.grid-cell")); if (colNumber >= cells.Count) { Assert.Fail("Row only has " + cells.Count + " columns"); } var cell = new WebDriverTableCell(Driver, Waiter, _tableSelectorString + " td.grid-cell#" + cells[colNumber].GetAttribute("id")); var cellValue = cell.GetText(); return(cellValue); }
private void FindCellToEnterText(int rowNumber, int colNumber, Action <WebDriverTableCell> action) { var rows = Element.FindElements(By.CssSelector("tr.grid-row")); if (rowNumber >= rows.Count) { Assert.Fail("Table only has " + rows.Count + " rows"); } var cells = rows[rowNumber].FindElements(By.CssSelector("td.grid-cell")); if (colNumber >= cells.Count) { Assert.Fail("Row only has " + cells.Count + " columns"); } var cell = new WebDriverTableCell(Driver, Waiter, _tableSelectorString + " td.grid-cell#" + cells[colNumber].GetAttribute("id") + " input"); action(cell); }
private void FindCellThen(int rowNumber, int colNumber, Action <WebDriverTableCell> action) { var rows = Element.FindElements(By.CssSelector("tr.grid-row")); if (rows.Count == 0) { Assert.Fail("Table has 0 rows"); } if (rowNumber >= rows.Count) { Assert.Fail("Table only has " + rows.Count + " rows"); } var cells = rows[rowNumber].FindElements(By.CssSelector("td.grid-cell")); if (colNumber >= cells.Count) { Assert.Fail("Row only has " + cells.Count + " columns"); } //Start of ID escape modification //This was added as a selenium update now means that rules are being applied to ID's starting with a number when using a css-selector //ID's starting with a number have to be escaped this is what the \3 is for, we also add a space after our first number as this would //be needed for where our ID has two or more numbers at the start of the ID. //An example is an ID of 0_Name becomes \30 _Name, and 12_Name would become \31 2_Name. var tableCellIdModifier = cells[colNumber].GetAttribute("id"); Char[] escapeIdStartingWithNumber = tableCellIdModifier.ToCharArray(); if (Char.IsNumber(escapeIdStartingWithNumber[0])) { tableCellIdModifier = tableCellIdModifier.Insert(0, "\\3"); tableCellIdModifier = tableCellIdModifier.Insert(3, " "); } var cell = new WebDriverTableCell(Driver, Waiter, _tableSelectorString + " td.grid-cell#" + tableCellIdModifier); //End of ID escape modification //old method encase we need it back action(cell); }