try { webClient.waitForBackgroundJavaScript(500); tempPage = domElement.click(); Thread.sleep(500); DomElement surge_url = tempPage.getElementById("surge_url");
/** * Simulates clicking on this element, returning the page in the window that has the focus * after the element has been clicked. Note that the returned page may or may not be the same * as the original page, depending on the type of element being clicked, the presence of JavaScript * action listeners, etc. * * @param <P> the page type * @return the page contained in the current window as returned by {@link WebClient#getCurrentWindow()} * @exception IOException if an IO error occurs */ public <P extends Page> P click() throws IOException { return click(false, false, false); }
/** * Simulates clicking on this element, returning the page in the window that has the focus * after the element has been clicked. Note that the returned page may or may not be the same * as the original page, depending on the type of element being clicked, the presence of JavaScript * action listeners, etc. * * @param <P> the page type * @return the page contained in the current window as returned by {@link WebClient#getCurrentWindow()} * @exception IOException if an IO error occurs */ public <P extends Page> P click() throws IOException { return click(false, false, false); }
DomElement button = page.getFirstByXPath("//input[@name='Submit']"); HtmlPage new_page = button.click(); // or you can use the old page
/** * Simulates clicking on this element, returning the page in the window that has the focus * after the element has been clicked. Note that the returned page may or may not be the same * as the original page, depending on the type of element being clicked, the presence of JavaScript * action listeners, etc. * * @param shiftKey {@code true} if SHIFT is pressed during the click * @param ctrlKey {@code true} if CTRL is pressed during the click * @param altKey {@code true} if ALT is pressed during the click * @param triggerMouseEvents if true trigger the mouse events also * @param <P> the page type * @return the page contained in the current window as returned by {@link WebClient#getCurrentWindow()} * @exception IOException if an IO error occurs */ public <P extends Page> P click(final boolean shiftKey, final boolean ctrlKey, final boolean altKey, final boolean triggerMouseEvents) throws IOException { return click(shiftKey, ctrlKey, altKey, triggerMouseEvents, false, false); }
/** * Simulates clicking on this element, returning the page in the window that has the focus * after the element has been clicked. Note that the returned page may or may not be the same * as the original page, depending on the type of element being clicked, the presence of JavaScript * action listeners, etc. * * @param shiftKey {@code true} if SHIFT is pressed during the click * @param ctrlKey {@code true} if CTRL is pressed during the click * @param altKey {@code true} if ALT is pressed during the click * @param <P> the page type * @return the page contained in the current window as returned by {@link WebClient#getCurrentWindow()} * @exception IOException if an IO error occurs */ public <P extends Page> P click(final boolean shiftKey, final boolean ctrlKey, final boolean altKey) throws IOException { return click(shiftKey, ctrlKey, altKey, true); }
/** * Simulates clicking on this element, returning the page in the window that has the focus * after the element has been clicked. Note that the returned page may or may not be the same * as the original page, depending on the type of element being clicked, the presence of JavaScript * action listeners, etc. * * @param shiftKey {@code true} if SHIFT is pressed during the click * @param ctrlKey {@code true} if CTRL is pressed during the click * @param altKey {@code true} if ALT is pressed during the click * @param triggerMouseEvents if true trigger the mouse events also * @param <P> the page type * @return the page contained in the current window as returned by {@link WebClient#getCurrentWindow()} * @exception IOException if an IO error occurs */ public <P extends Page> P click(final boolean shiftKey, final boolean ctrlKey, final boolean altKey, final boolean triggerMouseEvents) throws IOException { return click(shiftKey, ctrlKey, altKey, triggerMouseEvents, false, false); }
/** * Simulates clicking on this element, returning the page in the window that has the focus * after the element has been clicked. Note that the returned page may or may not be the same * as the original page, depending on the type of element being clicked, the presence of JavaScript * action listeners, etc. * * @param shiftKey {@code true} if SHIFT is pressed during the click * @param ctrlKey {@code true} if CTRL is pressed during the click * @param altKey {@code true} if ALT is pressed during the click * @param <P> the page type * @return the page contained in the current window as returned by {@link WebClient#getCurrentWindow()} * @exception IOException if an IO error occurs */ public <P extends Page> P click(final boolean shiftKey, final boolean ctrlKey, final boolean altKey) throws IOException { return click(shiftKey, ctrlKey, altKey, true); }
DomElement button = (DomElement) form.getFirstByXPath("//button[@id='logincontrol_submitbutton']"); text.setValueAttribute("Ziplok Java"); HtmlPage resultPage = (HtmlPage) button.click(); System.out.println(resultPage.asText());
/** * Dispatches an event into the event system (standards-conformant browsers only). See * <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent">the Gecko * DOM reference</a> for more information. * * @param event the event to be dispatched * @return {@code false} if at least one of the event handlers which handled the event * called <tt>preventDefault</tt>; {@code true} otherwise */ @JsxFunction public boolean dispatchEvent(final Event event) { event.setTarget(this); final DomElement element = (DomElement) getDomNodeOrNull(); ScriptResult result = null; if (event.getType().equals(MouseEvent.TYPE_CLICK)) { try { element.click(event, true); } catch (final IOException e) { throw Context.reportRuntimeError("Error calling click(): " + e.getMessage()); } } else { result = fireEvent(event); } return !event.isAborted(result); }
/** * Dispatches an event into the event system (standards-conformant browsers only). See * <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent">the Gecko * DOM reference</a> for more information. * * @param event the event to be dispatched * @return {@code false} if at least one of the event handlers which handled the event * called <tt>preventDefault</tt>; {@code true} otherwise */ @JsxFunction public boolean dispatchEvent(final Event event) { event.setTarget(this); final DomElement element = (DomElement) getDomNodeOrNull(); ScriptResult result = null; if (event.getType().equals(MouseEvent.TYPE_CLICK)) { try { element.click(event, true); } catch (final IOException e) { throw Context.reportRuntimeError("Error calling click(): " + e.getMessage()); } } else { result = fireEvent(event); } return !event.isAborted(result); }
@Override public void submit() { try { if (element instanceof HtmlForm) { submitForm((HtmlForm) element); return; } else if ((element instanceof HtmlSubmitInput) || (element instanceof HtmlImageInput)) { element.click(); return; } else if (element instanceof HtmlInput) { HtmlForm form = ((HtmlElement) element).getEnclosingForm(); if (form == null) { throw new NoSuchElementException("Unable to find the containing form"); } submitForm(form); return; } WebElement form = findParentForm(); if (form == null) { throw new NoSuchElementException("Unable to find the containing form"); } form.submit(); } catch (IOException e) { throw new WebDriverException(e); } }
event.disableProcessLabelAfterBubbling(); return click(event, ignoreVisibility);
event.disableProcessLabelAfterBubbling(); return click(event, ignoreVisibility);