HtmlTableRow tr = (HtmlTableRow) page.getByXPath("//tr[@class='odd']/"); for (HtmlTableCell td: tr.getCells() ) { if (td.getTextContent().isEmpty()) { // this is null } }
@Override protected List<DomNode> computeElements() { return new ArrayList<>(row.getCells()); } };
@Override protected List<DomNode> computeElements() { return new ArrayList<>(row.getCells()); } };
for (final HtmlTableRow row : table.getRows()) { System.out.println("Found row"); for (final HtmlTableCell cell : row.getCells()) { System.out.println(" Found cell: " + cell.asText()); } }
/** * Process {@link HtmlTableRow}. * * @param builder the StringBuilder to add to * @param htmlTableRow the target to process */ protected void appendTableRow(final StringBuilder builder, final HtmlTableRow htmlTableRow) { boolean first = true; for (final HtmlTableCell cell : htmlTableRow.getCells()) { if (!first) { builder.append(AS_TEXT_TAB); } else { first = false; } appendChildren(builder, cell); // trim? } }
/** * Returns the index of this cell within the parent row. * @return the index of this cell within the parent row * @see <a href="http://msdn.microsoft.com/en-us/library/ms533549.aspx">MSDN Documentation</a> */ public Integer jsxGet_cellIndex() { final HtmlTableCell cell = (HtmlTableCell) getDomNodeOrDie(); final HtmlTableRow row = cell.getEnclosingRow(); return new Integer(row.getCells().indexOf(cell)); }
/** * Process {@link HtmlTableRow}. * * @param builder the StringBuilder to add to * @param htmlTableRow the target to process */ protected void appendTableRow(final StringBuilder builder, final HtmlTableRow htmlTableRow) { boolean first = true; for (final HtmlTableCell cell : htmlTableRow.getCells()) { if (!first) { builder.append(AS_TEXT_TAB); } else { first = false; } appendChildren(builder, cell); // trim? } }
/** * Returns the index of this cell within the parent row. * @return the index of this cell within the parent row * @see <a href="http://msdn.microsoft.com/en-us/library/ms533549.aspx">MSDN Documentation</a> */ public Integer jsxGet_cellIndex() { final HtmlTableCell cell = (HtmlTableCell) getDomNodeOrDie(); final HtmlTableRow row = cell.getEnclosingRow(); return new Integer(row.getCells().indexOf(cell)); }
/** * Returns the index of this cell within the parent row. * @return the index of this cell within the parent row * @see <a href="http://msdn.microsoft.com/en-us/library/ms533549.aspx">MSDN Documentation</a> */ public Integer jsxGet_cellIndex() { final HtmlTableCell cell = (HtmlTableCell) getDomNodeOrDie(); final HtmlTableRow row = cell.getEnclosingRow(); return new Integer(row.getCells().indexOf(cell)); }
/** * Returns the index of this cell within the parent row. * @return the index of this cell within the parent row * @see <a href="http://msdn.microsoft.com/en-us/library/ms533549.aspx">MSDN Documentation</a> */ @JsxGetter public Integer getCellIndex() { final HtmlTableCell cell = (HtmlTableCell) getDomNodeOrDie(); final HtmlTableRow row = cell.getEnclosingRow(); if (row == null) { // a not attached document.createElement('TD') return Integer.valueOf(-1); } return Integer.valueOf(row.getCells().indexOf(cell)); }
private void appendHtmlTableRow(final HtmlTableRow htmlTableRow) { boolean first = true; for (final HtmlTableCell cell : htmlTableRow.getCells()) { if (!first) { doAppendTab(); } else { first = false; } appendChildren(cell); // trim? } }
private void appendHtmlTableRow(final HtmlTableRow htmlTableRow) { boolean first = true; for (final HtmlTableCell cell : htmlTableRow.getCells()) { if (!first) { doAppendTab(); } else { first = false; } appendChildren(cell); // trim? } }
private void appendHtmlTableRow(final HtmlTableRow htmlTableRow) { boolean first = true; for (final HtmlTableCell cell : htmlTableRow.getCells()) { if (!first) { doAppendTab(); } else { first = false; } appendChildren(cell); // trim? } }
/** * Returns the index of this cell within the parent row. * @return the index of this cell within the parent row * @see <a href="http://msdn.microsoft.com/en-us/library/ms533549.aspx">MSDN Documentation</a> */ @JsxGetter public Integer getCellIndex() { final HtmlTableCell cell = (HtmlTableCell) getDomNodeOrDie(); final HtmlTableRow row = cell.getEnclosingRow(); if (row == null) { // a not attached document.createElement('TD') return Integer.valueOf(-1); } return Integer.valueOf(row.getCells().indexOf(cell)); }
/** * 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(); } }
/** * 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. */ @JsxFunction public void deleteCell(final Object index) { int position = -1; if (index != Undefined.instance) { position = (int) Context.toNumber(index); } else if (getBrowserVersion().hasFeature(JS_TABLE_ROW_DELETE_CELL_REQUIRES_INDEX)) { 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(); }
/** * 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"); }
/** * {@inheritDoc} */ @Override public int jsxGet_offsetWidth() { float w = super.jsxGet_offsetWidth(); final MouseEvent event = MouseEvent.getCurrentMouseEvent(); if (isAncestorOfEventTarget(event)) { return (int) w; } final ComputedCSSStyleDeclaration style = jsxGet_currentStyle(); if ("collapse".equals(style.jsxGet_borderCollapse())) { final HtmlTableRow row = getRow(); if (row != null) { final HtmlElement thiz = getDomNodeOrDie(); final List<HtmlTableCell> cells = row.getCells(); final boolean ie = getBrowserVersion().isIE(); final boolean leftmost = (cells.indexOf(thiz) == 0); final boolean rightmost = (cells.indexOf(thiz) == cells.size() - 1); w -= ((ie && leftmost ? 0 : 0.5) * style.getBorderLeft()); w -= ((ie && rightmost ? 0 : 0.5) * style.getBorderRight()); } } return (int) w; }
/** * {@inheritDoc} */ @Override public int jsxGet_offsetWidth() { float w = super.jsxGet_offsetWidth(); final MouseEvent event = MouseEvent.getCurrentMouseEvent(); if (isAncestorOfEventTarget(event)) { return (int) w; } final ComputedCSSStyleDeclaration style = jsxGet_currentStyle(); if ("collapse".equals(style.jsxGet_borderCollapse())) { final HtmlTableRow row = getRow(); if (row != null) { final HtmlElement thiz = getDomNodeOrDie(); final List<HtmlTableCell> cells = row.getCells(); final boolean ie = getBrowserVersion().isIE(); final boolean leftmost = (cells.indexOf(thiz) == 0); final boolean rightmost = (cells.indexOf(thiz) == cells.size() - 1); w -= ((ie && leftmost ? 0 : 0.5) * style.getBorderLeft()); w -= ((ie && rightmost ? 0 : 0.5) * style.getBorderRight()); } } return (int) w; }
/** * {@inheritDoc} */ @Override public int getOffsetWidth() { float w = super.getOffsetWidth(); final MouseEvent event = MouseEvent.getCurrentMouseEvent(); if (isAncestorOfEventTarget(event)) { return (int) w; } if (isDisplayNone()) { return 0; } final ComputedCSSStyleDeclaration style = getWindow().getComputedStyle(this, null); if ("collapse".equals(style.getStyleAttribute(StyleAttributes.Definition.BORDER_COLLAPSE))) { final HtmlTableRow row = getRow(); if (row != null) { final HtmlElement thiz = getDomNodeOrDie(); final List<HtmlTableCell> cells = row.getCells(); final boolean ie = getBrowserVersion().hasFeature(JS_TABLE_CELL_OFFSET_INCLUDES_BORDER); final boolean leftmost = cells.indexOf(thiz) == 0; final boolean rightmost = cells.indexOf(thiz) == cells.size() - 1; w -= (ie && leftmost ? 0 : 0.5) * style.getBorderLeftValue(); w -= (ie && rightmost ? 0 : 0.5) * style.getBorderRightValue(); } } return (int) w; }