HtmlTableRow tr = (HtmlTableRow) page.getByXPath("//tr[@class='odd']/"); for (HtmlTableCell td: tr.getCells() ) { if (td.getTextContent().isEmpty()) { // this is null } }
var row = new HtmlTableRow(); var cell = new HtmlTableCell(); cell.InnerText = "Mac Address : " + "1111"; row.Cells.Add(cell); tableMain.Rows.Add(row);
/** * @param index the 0-based index * @return the cell at the given index * @throws IndexOutOfBoundsException if there is no cell at the given index */ public HtmlTableCell getCell(final int index) throws IndexOutOfBoundsException { int count = 0; for (final HtmlTableCell cell : getCellIterator()) { if (count == index) { return cell; } count++; } throw new IndexOutOfBoundsException("No cell found for index " + index + "."); }
/** * Inserts a new cell at the specified index in the element's cells collection. If the index * is -1 or there is no index specified, then the cell is appended at the end of the * element's cells collection. * @see <a href="http://msdn.microsoft.com/en-us/library/ms536455.aspx">MSDN Documentation</a> * @param index specifies where to insert the cell in the tr. * The default value is -1, which appends the new cell to the end of the cells collection * @return the newly-created cell */ public Object jsxFunction_insertCell(final Object index) { int position = -1; if (index != Undefined.instance) { position = (int) Context.toNumber(index); } final HtmlTableRow htmlRow = (HtmlTableRow) getDomNodeOrDie(); final boolean indexValid = (position >= -1 && position <= htmlRow.getCells().size()); if (indexValid) { final HtmlElement newCell = ((HtmlPage) htmlRow.getPage()).createElement("td"); if (position == -1 || position == htmlRow.getCells().size()) { htmlRow.appendChild(newCell); } else { htmlRow.getCell(position).insertBefore(newCell); } return getScriptableFor(newCell); } throw Context.reportRuntimeError("Index or size is negative or greater than the allowed amount"); }
/** * Deletes the cell at the specified index in the element's cells collection. If the index * is -1 (or while simulating IE, when there is no index specified), then the last cell is deleted. * @see <a href="http://msdn.microsoft.com/en-us/library/ms536406.aspx">MSDN Documentation</a> * @see <a href="http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-11738598">W3C DOM Level2</a> * @param index specifies the cell to delete. */ public void jsxFunction_deleteCell(final Object index) { int position = -1; if (index != Undefined.instance) { position = (int) Context.toNumber(index); } else if (getBrowserVersion().isFirefox()) { throw Context.reportRuntimeError("No enough arguments"); } final HtmlTableRow htmlRow = (HtmlTableRow) getDomNodeOrDie(); if (position == -1) { position = htmlRow.getCells().size() - 1; } final boolean indexValid = (position >= -1 && position <= htmlRow.getCells().size()); if (!indexValid) { throw Context.reportRuntimeError("Index or size is negative or greater than the allowed amount"); } htmlRow.getCell(position).remove(); } }
/** * Returns the index of the row within the parent table. * @return the index of the row within the parent table * @see <a href="http://msdn.microsoft.com/en-us/library/ms534377.aspx">MSDN Documentation</a> */ public int jsxGet_rowIndex() { final HtmlTableRow row = (HtmlTableRow) getDomNodeOrDie(); final HtmlTable table = row.getEnclosingTable(); return table.getRows().indexOf(row); }
private Book parseLibraryRow(HtmlPage p, HtmlTableRow r) { String xml = Util.cleanString(r.asXml()); if (r.getCells().size() == 0) return null; // empty row. if (xml.contains("/howtolisten")) { if (r.getCells().size() != BookColumns.size()) { LOG.error("wrong number of columns found: " + r.getCells().size() + " != " + BookColumns.size()); LOG.error(xml); if (debug) HTMLUtil.debugNode(r, "bad_col.xml"); List<HtmlElement> cells = r.getElementsByTagName("td");
/** * Gets the table containing this row. * @return the table */ public HtmlTable getEnclosingTable() { return (HtmlTable) getEnclosingElement("table"); }
/** * @return the next row from this iterator * @throws NoSuchElementException if no more rows are available */ public HtmlTableRow nextRow() throws NoSuchElementException { if (nextRow_ != null) { final HtmlTableRow result = nextRow_; setNextRow(nextRow_.getNextSibling()); return result; } throw new NoSuchElementException(); }
/** Creates an instance. */ public CellIterator() { setNextCell(getFirstChild()); }
for(HtmlTableRow row : billsTable.getBodies().get(0).getRows()){ String label = row.getCell(1).asText(); Date date = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse(row.getCell(0).asText()); BigDecimal amount =new BigDecimal(row.getCell(2).asText().replace("$", "")); String url = ((HtmlAnchor) row.getCell(3).getFirstChild()).getHrefAttribute();
/** * Inserts a new cell at the specified index in the element's cells collection. If the index * is -1 or there is no index specified, then the cell is appended at the end of the * element's cells collection. * @see <a href="http://msdn.microsoft.com/en-us/library/ms536455.aspx">MSDN Documentation</a> * @param index specifies where to insert the cell in the tr. * The default value is -1, which appends the new cell to the end of the cells collection * @return the newly-created cell */ public Object jsxFunction_insertCell(final Object index) { int position = -1; if (index != Undefined.instance) { position = (int) Context.toNumber(index); } final HtmlTableRow htmlRow = (HtmlTableRow) getDomNodeOrDie(); final boolean indexValid = (position >= -1 && position <= htmlRow.getCells().size()); if (indexValid) { final HtmlElement newCell = ((HtmlPage) htmlRow.getPage()).createElement("td"); if (position == -1 || position == htmlRow.getCells().size()) { htmlRow.appendChild(newCell); } else { htmlRow.getCell(position).insertBefore(newCell); } return getScriptableFor(newCell); } throw Context.reportRuntimeError("Index or size is negative or greater than the allowed amount"); }
/** * Deletes the cell at the specified index in the element's cells collection. If the index * is -1 (or while simulating IE, when there is no index specified), then the last cell is deleted. * @see <a href="http://msdn.microsoft.com/en-us/library/ms536406.aspx">MSDN Documentation</a> * @see <a href="http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-11738598">W3C DOM Level2</a> * @param index specifies the cell to delete. */ public void jsxFunction_deleteCell(final Object index) { int position = -1; if (index != Undefined.instance) { position = (int) Context.toNumber(index); } else if (getBrowserVersion().isFirefox()) { throw Context.reportRuntimeError("No enough arguments"); } final HtmlTableRow htmlRow = (HtmlTableRow) getDomNodeOrDie(); if (position == -1) { position = htmlRow.getCells().size() - 1; } final boolean indexValid = (position >= -1 && position <= htmlRow.getCells().size()); if (!indexValid) { throw Context.reportRuntimeError("Index or size is negative or greater than the allowed amount"); } htmlRow.getCell(position).remove(); } }
/** * Returns the index of the row within the parent table. * @return the index of the row within the parent table * @see <a href="http://msdn.microsoft.com/en-us/library/ms534377.aspx">MSDN Documentation</a> */ public int jsxGet_rowIndex() { final HtmlTableRow row = (HtmlTableRow) getDomNodeOrDie(); final HtmlTable table = row.getEnclosingTable(); return table.getRows().indexOf(row); }
/** * Gets the table containing this row. * @return the table */ public HtmlTable getEnclosingTable() { return (HtmlTable) getEnclosingElement("table"); }
/** * @return the next row from this iterator * @throws NoSuchElementException if no more rows are available */ public HtmlTableRow nextRow() throws NoSuchElementException { if (nextRow_ != null) { final HtmlTableRow result = nextRow_; setNextRow(nextRow_.getNextSibling()); return result; } throw new NoSuchElementException(); }
/** Creates an instance. */ public CellIterator() { setNextCell(getFirstChild()); }
/** * Inserts a new cell at the specified index in the element's cells collection. If the index * is -1 or there is no index specified, then the cell is appended at the end of the * element's cells collection. * @see <a href="http://msdn.microsoft.com/en-us/library/ms536455.aspx">MSDN Documentation</a> * @param index specifies where to insert the cell in the tr. * The default value is -1, which appends the new cell to the end of the cells collection * @return the newly-created cell */ public Object jsxFunction_insertCell(final Object index) { int position = -1; if (index != Undefined.instance) { position = (int) Context.toNumber(index); } final HtmlTableRow htmlRow = (HtmlTableRow) getDomNodeOrDie(); final boolean indexValid = (position >= -1 && position <= htmlRow.getCells().size()); if (indexValid) { final HtmlElement newCell = ((HtmlPage) htmlRow.getPage()).createElement("td"); if (position == -1 || position == htmlRow.getCells().size()) { htmlRow.appendChild(newCell); } else { htmlRow.getCell(position).insertBefore(newCell); } return getScriptableFor(newCell); } throw Context.reportRuntimeError("Index or size is negative or greater than the allowed amount"); }
@Override protected List<DomNode> computeElements() { return new ArrayList<>(row.getCells()); } };
/** * Deletes the cell at the specified index in the element's cells collection. If the index * is -1 (or while simulating IE, when there is no index specified), then the last cell is deleted. * @see <a href="http://msdn.microsoft.com/en-us/library/ms536406.aspx">MSDN Documentation</a> * @see <a href="http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-11738598">W3C DOM Level2</a> * @param index specifies the cell to delete. */ public void jsxFunction_deleteCell(final Object index) { int position = -1; if (index != Undefined.instance) { position = (int) Context.toNumber(index); } else if (getBrowserVersion().isFirefox()) { throw Context.reportRuntimeError("No enough arguments"); } final HtmlTableRow htmlRow = (HtmlTableRow) getDomNodeOrDie(); if (position == -1) { position = htmlRow.getCells().size() - 1; } final boolean indexValid = (position >= -1 && position <= htmlRow.getCells().size()); if (!indexValid) { throw Context.reportRuntimeError("Index or size is negative or greater than the allowed amount"); } htmlRow.getCell(position).remove(); } }