Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlAnchor


        final WebClient webClient = new WebClient();
        webClient.setJavaScriptEnabled( true );
        final HtmlPage page = webClient.getPage( uri.toURL() );

        final HtmlAnchor a =
            (HtmlAnchor) page.getByXPath( "//a[contains(@href, 'surefire260_TestB_testDup')]" ).get( 0 );
        final HtmlDivision content = (HtmlDivision) page.getElementById( "surefire260_TestB_testDuperror" );
        assertTrue( content.getAttribute( "style" ).contains( "none" ) );
        a.click();
        assertFalse( content.getAttribute( "style" ).contains( "none" ) );
        webClient.closeAllWindows();
    }
View Full Code Here


      //ignore
    }
    if (elt == null || !(elt instanceof HtmlAnchor)) {
      throw new StepFailedException("No link found with id >" + getHtmlId() + "<", this);
    }
    final HtmlAnchor webLink = (HtmlAnchor) elt;
    final String value = extractParameterValue(webLink.getHrefAttribute(), getParameter());
    if (value == null) {
      throw new StepFailedException("No parameter >" + getParameter() + "< found in link >"
         + webLink.getHrefAttribute() + "<", this);
    }
    storeProperty(value, getParameter());
  }
View Full Code Here

    }

  void visit(final HtmlPage currentResponse, final int depth) throws IOException {
    LOG.debug("report depth " + depth);
    for (final Iterator iter = currentResponse.getAnchors().iterator(); iter.hasNext();) {
      final HtmlAnchor link = (HtmlAnchor) iter.next();

      final Properties linkInfo = fValidator.validate(fDepth - depth, currentResponse, link);
      fReporter.write(linkInfo);
      if (depth > 0 && needsReport(link)) {
                processLink(link, depth);
View Full Code Here

    fHref = href;
  }

  protected Page findTarget() throws XPathException, IOException {
    final HtmlPage currentResp = getContext().getCurrentHtmlResponse(this);
    final HtmlAnchor link = (HtmlAnchor) findClickableElement(currentResp);

    if (link == null)
    {
      final StepFailedException e = new StepFailedException("Link not found in page " + currentResp.getWebResponse().getRequestUrl(), this);

      final StringBuffer sb = new StringBuffer();
      for (final Iterator iter = currentResp.getAnchors().iterator(); iter.hasNext();) {
        final HtmlAnchor webLink = (HtmlAnchor) iter.next();

        sb.append("- label \"").append(webLink.asText());
        sb.append("\" with url \"").append(webLink.getHrefAttribute());
        sb.append("\" and id \"").append(webLink.getIdAttribute());
        sb.append("\"\n");
      }
      e.addDetail("available links", sb.toString());
      throw e;
    }
View Full Code Here

  protected HtmlAnchor locateWebLink(final HtmlPage page) throws XPathException {
    return (HtmlAnchor) findClickableElement(page);
  }

  protected ClickableElement findClickableElementByAttribute(HtmlPage page) {
    HtmlAnchor link = locateTextLink(page);
    if (link != null) {
      return link;
    }
    return getLinkWithImageText(page, getLabel());
  }
View Full Code Here

    LOG.debug("Found " + li.size() + " images with alt=\"" + text + "\"");

    // looking for the first enclosing link
    for (final Iterator iter = li.iterator(); iter.hasNext();) {
      final HtmlElement elt = (HtmlElement) iter.next();
      final HtmlAnchor link = (HtmlAnchor) findParent("a", elt);
      if (link != null) {
        return link;
      }
    }
    return null;
View Full Code Here

  /**
   * @return null if not found
   */
  protected HtmlAnchor locateTextLink(final HtmlPage currentResponse) {
    for (final Iterator iter = currentResponse.getAnchors().iterator(); iter.hasNext();) {
      final HtmlAnchor curLink = (HtmlAnchor) iter.next();

      if (isMatching(curLink)) {
        return curLink;
      }
    }
View Full Code Here

    }

    private HtmlPage goToChangePreferredLocalePage(WebClient wc) throws Exception {
        login(wc);
        HtmlPage page = wc.getPage(url("/preferences/Preferences.action"));
        HtmlAnchor link = page.getAnchorByText("Choose your preferred language");
        HtmlPage result = link.click();
        wc.waitForBackgroundJavaScript(10000L);
        return result;
    }
View Full Code Here

    }

    private HtmlPage goToChangePasswordGenerationPreferencesPage(WebClient wc) throws Exception {
        login(wc);
        HtmlPage page = wc.getPage(url("/preferences/Preferences.action"));
        HtmlAnchor link = page.getAnchorByText("Random password generation preferences");
        HtmlPage result = link.click();
        wc.waitForBackgroundJavaScript(10000L);
        return result;
    }
View Full Code Here

    }

    protected void testPasswordGeneration(HtmlPage page, String formId) throws IOException {
        HtmlForm form = page.getHtmlElementById(formId);
        form.getInputByName("password").setValueAttribute("");
        HtmlAnchor generatePasswordLink = getFirstLinkByText(form, "Generate randomly");
        generatePasswordLink.click();
        assertEquals(8, form.getInputByName("password").getValueAttribute().length());
    }
View Full Code Here

TOP

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

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.