Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlInput


    System.out.println(page.asXml());   
    Element submitElement = page.getElementById("helloForm:submit");
    HtmlForm htmlForm = page.getFormByName("helloForm");
    htmlForm.getInputByName("helloForm:username");
    assertNotNull(htmlForm);
    HtmlInput input = htmlForm.getInputByName("helloForm:username");
    assertNotNull(input);
    input.setValueAttribute("foo");
    HtmlPage responsePage = (HtmlPage) htmlForm.submit((SubmittableElement) submitElement);
    assertNotNull(responsePage);
    System.out.println(responsePage.asXml());   
    HttpSession session = facesServer.getSession(false);
    assertNotNull(session);
View Full Code Here


        final String name = "John Doe";
        final String dateOfBirth = "1976-07-12";
        final String siblings = "2";

        // enter values
        HtmlInput nameInput = form.getInputByName("form:name");
        nameInput.setValueAttribute(name);
        HtmlInput dateOfBirthInput = form.getInputByName("form:dateOfBirth");
        dateOfBirthInput.setValueAttribute(dateOfBirth);
        HtmlInput siblingsInput = form.getInputByName("form:siblings");
        siblingsInput.setValueAttribute(siblings);

        // click commandButton
        HtmlSubmitInput submitButton = (HtmlSubmitInput) page.getElementById("form:submit");
        page = submitButton.click();
View Full Code Here

    public void testA() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
        HtmlPage page = (HtmlPage)new WebClient().getPage("http://localhost:8085/helloworld-servlet");

        HtmlForm form = (HtmlForm) page.getForms().get(0);

        HtmlInput textField = form.getInputByName("name");
        textField.setValueAttribute("petra");

        HtmlButton button = (HtmlButton) form.getButtonsByName("submit").get(0);

        HtmlPage pageResponse = (HtmlPage) button.click();
       
View Full Code Here

    */
   public void setInputNumberSpinner(String componentID, String value)
         throws IOException
   {
      DomNode tdTag = (DomNode)jsfClient.getElement(componentID + "Edit");
      HtmlInput input = (HtmlInput)tdTag.getChildNodes().item(0);
      input.setValueAttribute(value);
   }
View Full Code Here

   {
      DomNode table = (DomNode)jsfClient.getElement(componentID + "Buttons");
      List inputs = table.getByXPath("tbody/tr/td/input");
      for (Iterator i = inputs.iterator(); i.hasNext();)
      {
         HtmlInput input = (HtmlInput)i.next();
         if (input.asXml().contains(imageName))
         {
            input.click();
            return;
         }
      }
      throw new RuntimeException("Can't find image for " + imageName);
   }
View Full Code Here

    * @throws ClassCastException if the current page is not an HtmlPage.
    */
   public void setInputNumberSlider(String componentID, String value)
         throws IOException
   {
      HtmlInput input = (HtmlInput)jsfClient.getElement(componentID + "Input");
      input.setValueAttribute(value);
   }
View Full Code Here

        element.type(builder.toString());
      } catch (IOException e) {
        throw new WebDriverException(e);
      }
    } else if (element instanceof HtmlInput) {
      HtmlInput input = (HtmlInput) element;

      String currentValue = getValue();
      input.setValueAttribute((currentValue == null ? "" : currentValue) + builder.toString());
    } else if (element instanceof HtmlTextArea) {
      String currentValue = getValue();
      ((HtmlTextArea) element).setText(
          (currentValue == null ? "" : currentValue) + builder.toString());
    } else {
View Full Code Here

        final String xpath = "//input[@name='" + name + "']";
        final List< ? > list = page.getByXPath(xpath);
        if (list.isEmpty()) {
            throw new AssertionError("Unable to find an input element named '" + name + "'.");
        }
        final HtmlInput input = (HtmlInput) list.get(0);
        final String s = input.getValueAttribute();
        if (!s.equals(value)) {
            throw new AssertionError("The input element named '" + name + "' contains the value '" + s
                            + "', not the expected value '" + value + "'.");
        }
    }
View Full Code Here

        final String xpath = "//input[@name='" + name + "']";
        final List< ? > list = page.getByXPath(xpath);
        if (list.isEmpty()) {
            throw new AssertionError("Unable to find an input element named '" + name + "'.");
        }
        final HtmlInput input = (HtmlInput) list.get(0);
        final String s = input.getValueAttribute();
        if (s.equals(value)) {
            throw new AssertionError("The input element named '" + name + "' contains the value '" + s
                            + "', not the expected value '" + value + "'.");
        }
    }
View Full Code Here

     * Sets the value of the attribute "type".
     * Note: this replace the DOM node with a new one.
     * @param newType the new type to set
     */
    public void jsxSet_type(final String newType) {
        HtmlInput input = getHtmlInputOrDie();

        if (!input.getTypeAttribute().equalsIgnoreCase(newType)) {
            final AttributesImpl attributes = readAttributes(input);
            final int index = attributes.getIndex("type");
            attributes.setValue(index, newType);

            final HtmlInput newInput = (HtmlInput) InputElementFactory.instance
                .createElement(input.getPage(), "input", attributes);

            if (input.getParentNode() != null) {
                input.getParentNode().replaceChild(newInput, input);
            }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.html.HtmlInput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.