WebClient client = new WebClient(); HtmlPage page = client.getPage("http://stackoverflow.com"); // create a submit button - it doesn't work with 'input' HtmlElement button = page.createElement("button"); button.setAttribute("type", "submit"); // append the button to the form HtmlElement form = ...; form.appendChild(button); // submit the form page = button.click();
/** * Appends a child element to this HTML element with the specified tag name * if this HTML element does not already have a child with that tag name. * Returns the appended child element, or the first existent child element * with the specified tag name if none was appended. * @param tagName the tag name of the child to append * @return the added child, or the first existing child if none was added */ public final HtmlElement appendChildIfNoneExists(final String tagName) { final HtmlElement child; final List<HtmlElement> children = getElementsByTagName(tagName); if (children.isEmpty()) { // Add a new child and return it. child = (HtmlElement) ((HtmlPage) getPage()).createElement(tagName); appendChild(child); } else { // Return the first existing child. child = children.get(0); } return child; }
/** * Appends a child element to this HTML element with the specified tag name * if this HTML element does not already have a child with that tag name. * Returns the appended child element, or the first existent child element * with the specified tag name if none was appended. * @param tagName the tag name of the child to append * @return the added child, or the first existing child if none was added */ public final HtmlElement appendChildIfNoneExists(final String tagName) { final HtmlElement child; final List<HtmlElement> children = getHtmlElementsByTagName(tagName); if (children.isEmpty()) { // Add a new child and return it. child = ((HtmlPage) getPage()).createElement(tagName); appendChild(child); } else { // Return the first existing child. child = children.get(0); } return child; }
/** * Appends a child element to this HTML element with the specified tag name * if this HTML element does not already have a child with that tag name. * Returns the appended child element, or the first existent child element * with the specified tag name if none was appended. * @param tagName the tag name of the child to append * @return the added child, or the first existing child if none was added */ public final HtmlElement appendChildIfNoneExists(final String tagName) { final HtmlElement child; final List<HtmlElement> children = getHtmlElementsByTagName(tagName); if (children.isEmpty()) { // Add a new child and return it. child = ((HtmlPage) getPage()).createElement(tagName); appendChild(child); } else { // Return the first existing child. child = children.get(0); } return child; }
/** * Appends a child element to this HTML element with the specified tag name * if this HTML element does not already have a child with that tag name. * Returns the appended child element, or the first existent child element * with the specified tag name if none was appended. * @param tagName the tag name of the child to append * @return the added child, or the first existing child if none was added */ public final HtmlElement appendChildIfNoneExists(final String tagName) { final HtmlElement child; final List<HtmlElement> children = getHtmlElementsByTagName(tagName); if (children.isEmpty()) { // Add a new child and return it. child = ((HtmlPage) getPage()).createElement(tagName); appendChild(child); } else { // Return the first existing child. child = children.get(0); } return child; }
/** * Appends a child element to this HTML element with the specified tag name * if this HTML element does not already have a child with that tag name. * Returns the appended child element, or the first existent child element * with the specified tag name if none was appended. * @param tagName the tag name of the child to append * @return the added child, or the first existing child if none was added */ public final HtmlElement appendChildIfNoneExists(final String tagName) { final HtmlElement child; final List<HtmlElement> children = getElementsByTagName(tagName); if (children.isEmpty()) { // Add a new child and return it. child = (HtmlElement) ((HtmlPage) getPage()).createElement(tagName); appendChild(child); } else { // Return the first existing child. child = children.get(0); } return child; }
/** * 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"); }
/** * 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"); }
/** * 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"); }
/** * 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 */ @JsxFunction public Object 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 DomElement 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"); }
HtmlButton submitButton = (HtmlButton) currentPage.createElement("button"); submitButton.setAttribute("type", "submit"); searchForm.appendChild(submitButton);
/** * 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 */ @JsxFunction public Object 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 DomElement 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"); }
HtmlButton submitButton = (HtmlButton) currentPage.createElement("button"); submitButton.setAttribute("type", "submit"); searchForm.appendChild(submitButton);
/** * Inserts a new row at the given position. * @param index the index where the row should be inserted (0 <= index < nbRows) * @return the inserted row */ public Object insertRow(final int index) { final HTMLCollection rows = (HTMLCollection) jsxGet_rows(); final int rowCount = rows.jsxGet_length(); final HtmlElement newRow = ((HtmlPage) getDomNodeOrDie().getPage()).createElement("tr"); if (rowCount == 0) { getDomNodeOrDie().appendChild(newRow); } else { final SimpleScriptable row = (SimpleScriptable) rows.jsxFunction_item(new Integer(index)); // if at the end, then in the same "sub-container" as the last existing row if (index >= rowCount - 1) { row.getDomNodeOrDie().getParentNode().appendChild(newRow); } else { row.getDomNodeOrDie().insertBefore(newRow); } } return getScriptableFor(newRow); }
username.setValueAttribute("username"); password.setValueAttribute("password"); HtmlElement button = (HtmlElement) page1.createElement("button"); button.setAttribute("type", "submit");
/** * Inserts a new row at the given position. * @param index the index where the row should be inserted (0 <= index <= nbRows) * @return the inserted row */ public Object insertRow(final int index) { final HTMLCollection rows = (HTMLCollection) getRows(); final int rowCount = rows.getLength(); final DomElement newRow = ((HtmlPage) getDomNodeOrDie().getPage()).createElement("tr"); if (rowCount == 0) { getDomNodeOrDie().appendChild(newRow); } else if (index == rowCount) { final SimpleScriptable row = (SimpleScriptable) rows.item(Integer.valueOf(index - 1)); row.getDomNodeOrDie().getParentNode().appendChild(newRow); } else { final SimpleScriptable row = (SimpleScriptable) rows.item(Integer.valueOf(index)); // if at the end, then in the same "sub-container" as the last existing row if (index > rowCount - 1) { row.getDomNodeOrDie().getParentNode().appendChild(newRow); } else { row.getDomNodeOrDie().insertBefore(newRow); } } return getScriptableFor(newRow); }
/** * Inserts a new row at the given position. * @param index the index where the row should be inserted (0 <= index < nbRows) * @return the inserted row */ public Object insertRow(final int index) { final HTMLCollection rows = (HTMLCollection) jsxGet_rows(); final int rowCount = rows.jsxGet_length(); final HtmlElement newRow = ((HtmlPage) getDomNodeOrDie().getPage()).createElement("tr"); if (rowCount == 0) { getDomNodeOrDie().appendChild(newRow); } else { final SimpleScriptable row = (SimpleScriptable) rows.jsxFunction_item(new Integer(index)); // if at the end, then in the same "sub-container" as the last existing row if (index >= rowCount - 1) { row.getDomNodeOrDie().getParentNode().appendChild(newRow); } else { row.getDomNodeOrDie().insertBefore(newRow); } } return getScriptableFor(newRow); }
/** * Inserts a new row at the given position. * @param index the index where the row should be inserted (0 <= index < nbRows) * @return the inserted row */ public Object insertRow(final int index) { final HTMLCollection rows = (HTMLCollection) jsxGet_rows(); final int rowCount = rows.jsxGet_length(); final HtmlElement newRow = ((HtmlPage) getDomNodeOrDie().getPage()).createElement("tr"); if (rowCount == 0) { getDomNodeOrDie().appendChild(newRow); } else { final SimpleScriptable row = (SimpleScriptable) rows.jsxFunction_item(new Integer(index)); // if at the end, then in the same "sub-container" as the last existing row if (index >= rowCount - 1) { row.getDomNodeOrDie().getParentNode().appendChild(newRow); } else { row.getDomNodeOrDie().insertBefore(newRow); } } return getScriptableFor(newRow); }
/** * Inserts a new row at the given position. * @param index the index where the row should be inserted (0 <= index <= nbRows) * @return the inserted row */ public Object insertRow(final int index) { final HTMLCollection rows = (HTMLCollection) getRows(); final int rowCount = rows.getLength(); final DomElement newRow = ((HtmlPage) getDomNodeOrDie().getPage()).createElement("tr"); if (rowCount == 0) { getDomNodeOrDie().appendChild(newRow); } else if (index == rowCount) { final SimpleScriptable row = (SimpleScriptable) rows.item(Integer.valueOf(index - 1)); row.getDomNodeOrDie().getParentNode().appendChild(newRow); } else { final SimpleScriptable row = (SimpleScriptable) rows.item(Integer.valueOf(index)); // if at the end, then in the same "sub-container" as the last existing row if (index > rowCount - 1) { row.getDomNodeOrDie().getParentNode().appendChild(newRow); } else { row.getDomNodeOrDie().insertBefore(newRow); } } return getScriptableFor(newRow); }
@Override protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception { HtmlForm form = authorizationPage.getFormByName("loginform"); final HtmlTextInput login = form.getInputByName("log"); login.setValueAttribute("testscribeup"); final HtmlPasswordInput passwd = form.getInputByName("pwd"); passwd.setValueAttribute("testpwdscribeup"); HtmlElement button = authorizationPage.createElement("button"); button.setAttribute("type", "submit"); form.appendChild(button); // HtmlButton button = form.getButtonByName("wp-submit"); final HtmlPage confirmPage = button.click(); form = confirmPage.getFormByName("loginform"); button = confirmPage.createElement("button"); button.setAttribute("type", "submit"); form.appendChild(button); // button = form.getButtonByName("wp-submit"); final HtmlPage callbackPage = button.click(); final String callbackUrl = callbackPage.getUrl().toString(); logger.debug("callbackUrl : {}", callbackUrl); return callbackUrl; }