Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlInput


    }

    private static boolean hasTextOrPasswordField(final HtmlForm form, final String name) {
        final List li = form.getInputsByName(name);
        for (final Iterator iter = li.iterator(); iter.hasNext();) {
            final HtmlInput element = (HtmlInput) iter.next();
            if (HtmlConstants.TEXT.equalsIgnoreCase(element.getTypeAttribute())
                    || HtmlConstants.PASSWORD.equalsIgnoreCase(element.getTypeAttribute())) {
                return true;
            }
        }
        return false;
    }
View Full Code Here


   * @throws com.canoo.webtest.engine.StepFailedException
   *          if no applicable button was found
   */
  public void doExecute() throws Exception {
    final List htmlInputs = findHtmlElements(getContext());
    final HtmlInput htmlInputElmt = (HtmlInput) AbstractSetFieldStep.selectField(htmlInputs, fFieldIndex, this);
    String retval = htmlInputElmt.getAttribute(fAttributeName);
    if (retval == HtmlElement.ATTRIBUTE_NOT_DEFINED) {
      retval = "false";
    } else if (retval == HtmlElement.ATTRIBUTE_VALUE_EMPTY || retval.length() == 0) {
      retval = "true";
    }
View Full Code Here

            fields = new ArrayList(((HtmlPage) context.getCurrentResponse()).getDocumentElement().getElementsByAttribute(HtmlConstants.INPUT, HtmlConstants.NAME, fFieldName));
        }
        // remove those not having the right value
        if (fFieldValue != null) {
            for (Iterator iter = fields.iterator(); iter.hasNext();) {
                final HtmlInput input = (HtmlInput) iter.next();
                if (!fFieldValue.equals(input.getValueAttribute())) {
                    iter.remove();
                }
            }
        }
        return fields;
View Full Code Here

  protected List findFields(HtmlForm form) {
    return form.getInputsByName(getName());
  }

  protected void verifyField(final HtmlElement field) throws IOException {
    final HtmlInput input = (HtmlInput) field;
    final String fieldContents = input.getValueAttribute();
    if (!verifyStrings(getValue(), fieldContents, getRegex())) {
      throw new StepFailedException("Wrong contents found in input field: " + input, getValue(), fieldContents);
    }

  }
View Full Code Here

    while (candidateIterator.hasNext()) {
      final HtmlElement curElement = (HtmlElement) candidateIterator.next();
      if (!(curElement instanceof HtmlInput)) {
        continue;
      }
      final HtmlInput curInput = (HtmlInput) curElement;
      if (!isInputButtonType(curInput)) {
        continue; // not a "button"
      }
      LOG.debug("Examining button: " + curInput);
      if (hasMatchingNameOrDontCare(curInput) && hasMatchingLabelOrDontCare(curInput)) {
        if (indexFound == ConversionUtil.convertToInt(getFieldIndex(), 0)) {
          LOG.debug(curInput.getTypeAttribute() + " button found: " + curInput);
          return curInput;
        }
        ++indexFound;
      }
    }
View Full Code Here

     */
    @Override
    public void execute() throws Exception
    {

        HtmlInput input0 = form.getInputByName("j_username");
        input0.setValueAttribute(username);

        HtmlInput input1 = form.getInputByName("j_password");
        input1.setValueAttribute(password);

        loadPageByClick(clickable, 10000);
    }
View Full Code Here

    private String getDecodedAuthnRequest(String content) throws Exception {
        StringWebResponse response = new StringWebResponse(content, new URL("http://localhost:8080/"));
        WebClient webClient = new WebClient();
        HtmlPage page = HTMLParser.parseHtml(response, webClient.getCurrentWindow());
        HtmlForm form = page.getForms().get(0);
        HtmlInput samlRequest = form.getInputByName("SAMLRequest");
        return new String(Base64.decodeBase64(samlRequest.getValueAttribute()));
    }
View Full Code Here

        client.setThrowExceptionOnFailingStatusCode(true);

        HtmlPage page = client.getPage(getPath("/storm.jsf"));
        HtmlSubmitInput invalidateSessionButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "invalidateSessionButton");
        page = invalidateSessionButton.click();
        HtmlInput inputField = getFirstMatchingElement(page, HtmlInput.class, "prop");
        Assert.assertEquals(Storm.PROPERTY_VALUE, inputField.getValueAttribute());

        // Make another request to verify that the session bean value is not the
        // one from the previous invalidated session.
        page = client.getPage(getPath("/storm.jsf"));
        inputField = getFirstMatchingElement(page, HtmlInput.class, "prop");
        Assert.assertEquals(SomeBean.DEFAULT_PROPERTY_VALUE, inputField.getValueAttribute());
    }
View Full Code Here

    protected HtmlInput getInputContainingGivenId(HtmlPage root,
              String id) {
  List list;
  int i;
  HtmlInput result = null;
 
  list = getAllElementsOfGivenClass(root, null, HtmlInput.class);
  for (i = 0; i < list.size(); i++) {
      result = (HtmlInput) list.get(i);
      if (-1 != result.getIdAttribute().indexOf(id)) {
    break;
      }
      result = null;
  }
  return result;
View Full Code Here

    protected HtmlInput getNthInputContainingGivenId(HtmlPage root,
                 String id,
                 int whichInput) {
  List list;
  int i, hitCount = 0;
  HtmlInput result = null;
 
  list = getAllElementsOfGivenClass(root, null, HtmlInput.class);
  for (i = 0; i < list.size(); i++) {
      result = (HtmlInput) list.get(i);
      if (-1 != result.getIdAttribute().indexOf(id) &&
    hitCount++ == whichInput) {
    break;
      }
      result = null;
  }
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.