/** * {@inheritDoc} */ public HtmlElement getElementById(final String elementId) { try { return getHtmlElementById(elementId); } catch (final ElementNotFoundException e) { return null; } }
/** * {@inheritDoc} */ public HtmlElement getElementById(final String elementId) { try { return getHtmlElementById(elementId); } catch (final ElementNotFoundException e) { return null; } }
/** * {@inheritDoc} */ public HtmlElement getElementById(final String elementId) { try { return getHtmlElementById(elementId); } catch (final ElementNotFoundException e) { return null; } }
private HtmlElement findById(String id) { try { return page.getHtmlElementById(id); } catch (Throwable th) { } return null; }
public HtmlElement getElementById(String id) { return currentPage.getHtmlElementById(id); }
/** * Verifies that the specified page does not contain an element with the specified ID. * * @param page the page to check * @param id the ID of an element which expected to not exist on the page */ public static void assertElementNotPresent(final HtmlPage page, final String id) { try { page.getHtmlElementById(id); } catch (final ElementNotFoundException e) { return; } final String msg = "The page contains an element with ID '" + id + "'."; throw new AssertionError(msg); }
/** * Verifies that the specified page contains an element with the specified ID. * * @param page the page to check * @param id the expected ID of an element in the page */ public static void assertElementPresent(final HtmlPage page, final String id) { try { page.getHtmlElementById(id); } catch (final ElementNotFoundException e) { final String msg = "The page does not contain an element with ID '" + id + "'."; throw new AssertionError(msg); } }
/** * Verifies that the specified page contains an element with the specified ID. * * @param page the page to check * @param id the expected ID of an element in the page */ public static void assertElementPresent(final HtmlPage page, final String id) { try { page.getHtmlElementById(id); } catch (final ElementNotFoundException e) { final String msg = "The page does not contain an element with ID '" + id + "'."; throw new AssertionError(msg); } }
private HtmlElement getHtmlElement(String anID) { try { return ((HtmlPage) win.getEnclosedPage()).getHtmlElementById(anID); } catch (ElementNotFoundException e) { return null; } }
/** * Returns the element in this element's page with the specified ID. If more than one element * has the specified ID (not allowed by the HTML spec), this method returns the first one. * * @param id the ID value to search for * @param <E> the sub-element type * @return the element in this element's page with the specified ID * @exception ElementNotFoundException if no element has the specified ID */ @SuppressWarnings("unchecked") public <E extends HtmlElement> E getElementById(final String id) throws ElementNotFoundException { return (E) ((HtmlPage) getPage()).getHtmlElementById(id); }
/** * Returns the element in this element's page with the specified ID. If more than one element * has the specified ID (not allowed by the HTML spec), this method returns the first one. * * @param id the ID value to search for * @param <E> the sub-element type * @return the element in this element's page with the specified ID * @exception ElementNotFoundException if no element has the specified ID */ @SuppressWarnings("unchecked") public <E extends HtmlElement> E getElementById(final String id) throws ElementNotFoundException { return (E) ((HtmlPage) getPage()).getHtmlElementById(id); }
/** * Returns the element in this element's page with the specified ID. If more than one element * has the specified ID (not allowed by the HTML spec), this method returns the first one. * * @param id the ID value to search for * @param <E> the sub-element type * @return the element in this element's page with the specified ID * @exception ElementNotFoundException if no element has the specified ID */ @SuppressWarnings("unchecked") public <E extends HtmlElement> E getElementById(final String id) throws ElementNotFoundException { return (E) ((HtmlPage) getPage()).getHtmlElementById(id); }
/** * Return true if a link is present in the current response with the specified id. * * @param anId link id to check for. */ @Override public boolean hasLink(String anId) { try { ((HtmlPage) win.getEnclosedPage()).getHtmlElementById(anId); } catch (ElementNotFoundException e) { return false; } return true; }
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) { final HtmlPage page = webClient.getPage("http://www.aastocks.com/en/stock/DetailQuote.aspx?&symbol1"); HtmlInput input = page.getHtmlElementById("PY_txt"); input.type("328"); final HtmlPage page2 = page.getHtmlElementById("imgHKStockSubmit").click(); System.out.println(page2.getUrl()); System.out.println(page2.asText()); }
private HtmlForm getForm(String nameOrID) { try { return (HtmlForm) ((HtmlPage) win.getEnclosedPage()) .getHtmlElementById(nameOrID); } catch (ElementNotFoundException e) { } try { return ((HtmlPage) win.getEnclosedPage()).getFormByName(nameOrID); } catch (ElementNotFoundException e) { } return null; }
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) { HtmlPage page = webClient.getPage("http://www.google.com"); HtmlAnchor a = page.getHtmlElementById("gb_70"); page = a.click(); HtmlForm form = (HtmlForm) page.getElementById("gaia_loginform"); HtmlTextInput email = (HtmlTextInput) page.getElementById("Email"); email.setValueAttribute(myEmailAddress); HtmlSubmitInput nextButton = page.getHtmlElementById("next"); System.out.println(nextButton.asXml()); HtmlPage newWebpage = nextButton.click(); String status = newWebpage.getWebResponse().getStatusMessage(); System.out.println(status); }
@Test public void getElements() throws Exception { try (final WebClient webClient = new WebClient()) { final HtmlPage page = webClient.getPage("http://some_url"); final HtmlDivision div = page.getHtmlElementById("some_div_id"); final HtmlAnchor anchor = page.getAnchorByName("anchor_name"); } }
`@Test public void getElements() throws Exception { final WebClient webClient = new WebClient(); final HtmlPage page = webClient.getPage("http://some_url"); final HtmlDivision div = page.getHtmlElementById("some_div_id"); final HtmlAnchor anchor = page.getAnchorByName("anchor_name"); webClient.closeAllWindows(); }`
@Override public WebElement findElementById(String id) { if (!(lastPage() instanceof HtmlPage)) { throw new NoSuchElementException("Unable to locate element by id for " + lastPage()); } try { HtmlElement element = ((HtmlPage) lastPage()).getHtmlElementById(id); return newHtmlUnitWebElement(element); } catch (ElementNotFoundException e) { throw new NoSuchElementException("Unable to locate element with ID: " + id); } }
public WebElement findElementById(String id) { if (!(lastPage() instanceof HtmlPage)) throw new NoSuchElementException("Cannot find element by id for " + lastPage()); try { HtmlElement element = ((HtmlPage) lastPage()).getHtmlElementById(id); return newHtmlUnitWebElement(element); } catch (ElementNotFoundException e) { throw new NoSuchElementException("Cannot find element with ID: " + id); } }