/** * Simulates typing the specified key code while this element has focus, returning the page contained * by this element's window after typing. Note that it may or may not be the same as the original page, * depending on the JavaScript event handlers, etc. Note also that for some elements, typing <tt>XXXXXXXXXXX</tt> * submits the enclosed form. * * An example of predefined values is {@link KeyboardEvent#DOM_VK_PAGE_DOWN}. * * @param keyCode the key code to simulate typing * @return the page that occupies this window after typing */ public Page type(final int keyCode) { return type(keyCode, false, true, true, true, true); }
/** * Simulates typing the specified character while this element has focus, returning the page contained * by this element's window after typing. Note that it may or may not be the same as the original page, * depending on the JavaScript event handlers, etc. Note also that for some elements, typing <tt>'\n'</tt> * submits the enclosed form. * * @param c the character you wish to simulate typing * @return the page that occupies this window after typing * @exception IOException if an IO error occurs */ public Page type(final char c) throws IOException { return type(c, true); }
/** * Simulates typing the specified character while this element has focus, returning the page contained * by this element's window after typing. Note that it may or may not be the same as the original page, * depending on the JavaScript event handlers, etc. Note also that for some elements, typing <tt>'\n'</tt> * submits the enclosed form. * * @param c the character you wish to simulate typing * @return the page that occupies this window after typing * @exception IOException if an IO error occurs */ public Page type(final char c) throws IOException { return type(c, false, true); }
/** * Simulates typing the specified character while this element has focus, returning the page contained * by this element's window after typing. Note that it may or may not be the same as the original page, * depending on the JavaScript event handlers, etc. Note also that for some elements, typing <tt>'\n'</tt> * submits the enclosed form. * * @param c the character you with to simulate typing * @return the page that occupies this window after typing * @exception IOException if an IO error occurs */ public Page type(final char c) throws IOException { return type(c, false, false, false); }
/** * Simulates typing the specified character while this element has focus, returning the page contained * by this element's window after typing. Note that it may or may not be the same as the original page, * depending on the JavaScript event handlers, etc. Note also that for some elements, typing <tt>'\n'</tt> * submits the enclosed form. * * @param c the character you with to simulate typing * @return the page that occupies this window after typing * @exception IOException if an IO error occurs */ public Page type(final char c) throws IOException { return type(c, false, false, false); }
/** * Simulates typing the specified character while this element has focus, returning the page contained * by this element's window after typing. Note that it may or may not be the same as the original page, * depending on the JavaScript event handlers, etc. Note also that for some elements, typing <tt>'\n'</tt> * submits the enclosed form. * * @param c the character you with to simulate typing * @return the page that occupies this window after typing * @exception IOException if an IO error occurs */ public Page type(final char c) throws IOException { return type(c, false, false, false); }
/** * Simulates typing the specified key code while this element has focus, returning the page contained * by this element's window after typing. Note that it may or may not be the same as the original page, * depending on the JavaScript event handlers, etc. Note also that for some elements, typing <tt>XXXXXXXXXXX</tt> * submits the enclosed form. * * An example of predefined values is {@link KeyboardEvent#DOM_VK_PAGE_DOWN}. * * @param keyCode the key code to simulate typing * @return the page that occupies this window after typing */ public Page type(final int keyCode) { return type(keyCode, true, true, true, true); }
/** * Simulates typing the specified text while this element has focus. * Note that for some elements, typing '\n' submits the enclosed form. * @param text the text you with to simulate typing * @exception IOException If an IO error occurs */ public void type(final String text) throws IOException { for (final char ch : text.toCharArray()) { type(ch); } }
/** * Simulates typing the specified text while this element has focus. * Note that for some elements, typing '\n' submits the enclosed form. * @param text the text you with to simulate typing * @exception IOException If an IO error occurs */ public void type(final String text) throws IOException { for (final char ch : text.toCharArray()) { type(ch); } }
/** * Simulates typing the specified text while this element has focus. * Note that for some elements, typing '\n' submits the enclosed form. * @param text the text you with to simulate typing * @exception IOException If an IO error occurs */ public void type(final String text) throws IOException { for (final char ch : text.toCharArray()) { type(ch); } }
/** * Simulates typing the specified text while this element has focus. * Note that for some elements, typing '\n' submits the enclosed form. * @param text the text you with to simulate typing * @exception IOException If an IO error occurs */ public void type(final String text) throws IOException { for (final char ch : text.toCharArray()) { type(ch); } }
/** * Simulates typing the specified text while this element has focus. * Note that for some elements, typing '\n' submits the enclosed form. * @param text the text you with to simulate typing * @exception IOException If an IO error occurs */ public void type(final String text) throws IOException { for (final char ch : text.toCharArray()) { type(ch); } }
/** * Simulates typing the specified text while this element has focus. * Note that for some elements, typing '\n' submits the enclosed form. * @param text the text you with to simulate typing * @param shiftKey true if SHIFT is pressed * @param ctrlKey true if CTRL is pressed * @param altKey true if ALT is pressed * @exception IOException If an IO error occurs */ public void type(final String text, final boolean shiftKey, final boolean ctrlKey, final boolean altKey) throws IOException { for (final char ch : text.toCharArray()) { type(ch, shiftKey, ctrlKey, altKey); } }
/** * Simulates typing the specified text while this element has focus. * Note that for some elements, typing '\n' submits the enclosed form. * @param text the text you with to simulate typing * @param shiftKey true if SHIFT is pressed * @param ctrlKey true if CTRL is pressed * @param altKey true if ALT is pressed * @exception IOException If an IO error occurs */ public void type(final String text, final boolean shiftKey, final boolean ctrlKey, final boolean altKey) throws IOException { for (final char ch : text.toCharArray()) { type(ch, shiftKey, ctrlKey, altKey); } }
/** * Simulates typing the specified text while this element has focus. * Note that for some elements, typing '\n' submits the enclosed form. * @param text the text you with to simulate typing * @param shiftKey true if SHIFT is pressed * @param ctrlKey true if CTRL is pressed * @param altKey true if ALT is pressed * @exception IOException If an IO error occurs */ public void type(final String text, final boolean shiftKey, final boolean ctrlKey, final boolean altKey) throws IOException { for (final char ch : text.toCharArray()) { type(ch, shiftKey, ctrlKey, altKey); } }
/** * Performs the effective type action, called after the keyPress event and before the keyUp event. * @param c the character you with to simulate typing * @param startAtEnd whether typing should start at the text end or not * @param lastType is this the last character to type */ protected void doType(final char c, final boolean startAtEnd, final boolean lastType) { final DomNode domNode = getDoTypeNode(); if (domNode instanceof DomText) { ((DomText) domNode).doType(c, startAtEnd, this, lastType); } else if (domNode instanceof HtmlElement) { try { ((HtmlElement) domNode).type(c, startAtEnd, lastType); } catch (final IOException e) { throw new RuntimeException(e); } } }
final HtmlPage page = webClient.getPage("http://www.google.com"); HtmlElement inputField = page.getElementByName("q"); inputField.type("Example input"); HtmlElement btnG = page.getElementByName("btnG"); Page secondPage = btnG.click(); if (secondPage instanceof HtmlPage) { System.out.println(page.getTitleText()); System.out.println(((HtmlPage)secondPage).getTitleText()); }
/** * Performs the effective type action, called after the keyPress event and before the keyUp event. * * An example of predefined values is {@link KeyboardEvent#DOM_VK_PAGE_DOWN}. * * @param keyCode the key code wish to simulate typing * @param lastType is this the last to type */ protected void doType(final int keyCode, final boolean lastType) { final DomNode domNode = getDoTypeNode(); if (domNode instanceof DomText) { ((DomText) domNode).doType(keyCode, this, lastType); } else if (domNode instanceof HtmlElement) { ((HtmlElement) domNode).type(keyCode, true, true, true, lastType); } }
/** * Simulates typing a character while this JSF component has focus. * * @param componentID The JSF component id (or a suffix of the client ID) of * a component rendered as an HtmlElement. * * @throws ComponentIDNotFoundException if no client ID matches the suffix * @throws DuplicateClientIDException if more than one client ID matches the suffix * @throws ClassCastException if the current page is not an HtmlPage or the * specified component is not an HtmlElement. * @throws IOExceptioin if typing causes a failed request to the server. */ public void type(String componentID, char c) throws IOException { HtmlElement element = (HtmlElement)getElement(componentID); if (element == null) throw new ComponentIDNotFoundException(componentID); element.type(c); }
/** * Performs the effective type action, called after the keyPress event and before the keyUp event. * * An example of predefined values is {@link KeyboardEvent#DOM_VK_PAGE_DOWN}. * * @param keyCode the key code wish to simulate typing * @param startAtEnd whether typing should start at the text end or not * @param lastType is this the last to type */ protected void doType(final int keyCode, final boolean startAtEnd, final boolean lastType) { final DomNode domNode = getDoTypeNode(); if (domNode instanceof DomText) { ((DomText) domNode).doType(keyCode, startAtEnd, this, lastType); } else if (domNode instanceof HtmlElement) { ((HtmlElement) domNode).type(keyCode, startAtEnd, true, true, true, lastType); } }