Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlOption


        HtmlElement element = (HtmlElement) form.selectSingleNode(".//tr[td/div/input/@value='choice']");
        assertNotNull(element);
        assertEquals("choice description", ((HtmlElement) element.selectSingleNode("td/div")).getAttribute("description"));
        assertEquals("choice", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent());
        HtmlOption opt = (HtmlOption)element.selectSingleNode("td/div/select/option[@value='Choice <2>']");
        assertNotNull(opt);
        assertEquals("Choice <2>", opt.asText());
        opt.setSelected(true);

        submit(form);
        Queue.Item q = hudson.getQueue().getItem(project);
        if (q != null) q.getFuture().get();
        else Thread.sleep(1000);
View Full Code Here


      Element element = getElement(parentID);
      HtmlSelect htmlSelect = (HtmlSelect)element;
     
      String optionValue = getSelectItemValue(componentID);
     
      HtmlOption htmlOption = htmlSelect.getOptionByValue(optionValue);
      htmlOption.click();
   }
View Full Code Here

        assertFalse(page.<HtmlElement>getHtmlElementById("newAlbumName").getAttribute("style").contains("display: none;"));
        assertFalse(page.<HtmlElement>getHtmlElementById("adminTableGallery").asXml().contains("photark/gallery/boston/dsc00376.jpg"));
        assertFalse(page.<HtmlElement>getHtmlElementById("adminTableGallery").asXml().contains("photark/gallery/boston/dsc00368.jpg"));

        //selecting an album from drop down
        HtmlOption option = select.getOption(1);
        option.click();
        Thread.sleep(3000);
        //testing whether the expected changes has happened
        assertTrue(select.asText().contains("boston"));
        assertTrue(page.<HtmlElement>getHtmlElementById("albumCover").asXml().contains("photark/gallery/boston/dsc"));
View Full Code Here

        assertFalse(page.<HtmlElement>getHtmlElementById("newAlbumName").getAttribute("style").contains("display: none;"));
        assertFalse(page.<HtmlElement>getHtmlElementById("adminTableGallery").asXml().contains("photark/gallery/boston/dsc00376.jpg"));
        assertFalse(page.<HtmlElement>getHtmlElementById("adminTableGallery").asXml().contains("photark/gallery/boston/dsc00368.jpg"));

        //selecting an album from drop down
        HtmlOption option = select.getOption(1);
        option.click();
        Thread.sleep(3000);
        //testing whether the expected changes has happened
        assertTrue(select.asText().contains("boston"));
        assertTrue(page.<HtmlElement>getHtmlElementById("albumCover").asXml().contains("photark/gallery/boston/dsc"));
View Full Code Here

        assertFalse(page.<HtmlElement>getHtmlElementById("newAlbumName").getAttribute("style").contains("display: none;"));
        assertFalse(page.<HtmlElement>getHtmlElementById("adminTableGallery").asXml().contains("photark/gallery/boston/dsc00376.jpg"));
        assertFalse(page.<HtmlElement>getHtmlElementById("adminTableGallery").asXml().contains("photark/gallery/boston/dsc00368.jpg"));

        //selecting an album from drop down
        HtmlOption option = select.getOption(1);
        option.click();
        Thread.sleep(3000);
        //testing whether the expected changes has happened
        assertTrue(select.asText().contains("boston"));
        assertTrue(page.<HtmlElement>getHtmlElementById("albumCover").asXml().contains("photark/gallery/boston/dsc"));
View Full Code Here

    return form.getSelectsByName(getName());
  }

  protected void setField(final HtmlElement elt) {
    final HtmlSelect select;
    final HtmlOption option;
    if (elt instanceof HtmlOption)
    {
      option = (HtmlOption) elt;
      select = (HtmlSelect) option.getEnclosingElement(HtmlConstants.SELECT); // TODO: can be simplified with next htmlunit build
    }
    else if (elt instanceof HtmlSelect)
    {
      select = (HtmlSelect) elt;
      // if htmlId or xpath specified, we know now first that text, value or optionIndex is needed
View Full Code Here

    select.setSelectedAttribute(option, true);
  }

  private static void deselectOtherOptions(final HtmlSelect select, final HtmlOption option) {
    for (final Iterator iter = select.getOptions().iterator(); iter.hasNext();) {
      final HtmlOption curOpt = (HtmlOption) iter.next();
      if (curOpt != option && curOpt.isSelected()) {
        curOpt.setSelected(false);
      }
    }
  }
View Full Code Here

   * @return The option element corresponding to the specified text
   */
  private HtmlOption getOptionForText(final HtmlSelect select, final String text) {
    final IStringVerifier verifier = getVerifier(fIsRegex);
    for (final Iterator iter = select.getOptions().iterator(); iter.hasNext();) {
      final HtmlOption option = (HtmlOption) iter.next();
      LOG.debug("Examining option: " + option);
      if (verifier.verifyStrings(text, option.asText())) {
        LOG.debug("Found option by text: " + option);
        return option;
      }
    }
    throw new StepFailedException("No option element found with text \"" + text + "\"", this);
View Full Code Here

  }

  protected void verifyField(final HtmlElement field) throws IOException {
    final HtmlSelect curSelect = (HtmlSelect) field;
    for (final Iterator iter = curSelect.getOptions().iterator(); iter.hasNext();) {
      final HtmlOption curOption = (HtmlOption) iter.next();

      if ((getText() == null || verifyStrings(getText(), curOption.asText()))
        && (getValue() == null || verifyStrings(getValue(), curOption.getValueAttribute()))) {
        LOG.debug("Found corresponding option " + curOption);
        if (curOption.isSelected()) {
          return;
        }
        throw new StepFailedException(getStepLabel() + ": " + buildFailMessage(getValue()), this);
      }
    }
View Full Code Here

        HtmlSelect adhocList = (HtmlSelect)adhocForm.getHtmlElementById("sqlQuery");
        List adhocListOptions = adhocList.getOptions();//.asText();
        //System.out.println(" adhocListOptionsText-->\n" + adhocListOptions.toString());
        String allOptionsText = "";
        for(int i=0; i<adhocListOptions.size(); i++){
          HtmlOption curOption = (HtmlOption)adhocListOptions.get(i);
          String curOptionText = curOption.getValueAttribute();
          allOptionsText = allOptionsText + curOptionText;
          if(curOptionText.equals("SELECT * FROM COMPANY")){
            adhocList.setSelectedAttribute(curOption, true);
            //System.out.println("select option..."+curOptionText);
          }
View Full Code Here

TOP

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

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.