2

I have a web form having JQuery dropdowns. The particular field holds date of birth. The source for the field is:

<div class="tooltipGroup" style="z-index:19;">
   <div class="day">
      <div class="jqTransformSelectWrapper" style="z-index: 19;">
      <div>
         <ul style="width: 100%; display: block; visibility: visible;">
          <li class="optHeading">
          <li class="undefined">
          <li class="undefined">
          <li class="undefined">
          <li class="undefined">
          <li class="undefined">
          <li class="undefined">
             <a index="6" href="#">6</a>
      </li>

         <li class="undefined">
             <a index="31" href="#">31</a>
       </li>

That's the code trying to get all of the elements and put them in a HashMap:

public void selectDob(int dob) {

        WebElement dobFieldDropdown;

        WebElement content = driver.findElement(By.className("leftClmn"));

        driver.findElement(By.id("aWrapper_dob_day")).click();

        dobFieldDropdown = content.findElements(By.className("tooltipGroup")).get(2).findElement(By.className("day")).findElement(By.tagName("ul"));

        HashMap<String, WebElement> dropdownValues = new HashMap<String, WebElement>();

        for (WebElement el : dobFieldDropdown.findElements(By.tagName("a"))) {
            dropdownValues.put(el.getText(), el);

            System.out.println(el.getText());
        }
        dropdownValues.get(dob).click();

    }

The code works just fine with one exception: it can't get the values of all fields, just the first visible when the dropdown is being opened.

1 2 3 4 5

The question is how to get the values of the other fields?

Atanas Kanchev
  • 697
  • 4
  • 12
  • 26
  • Kindly check the answer that i have provided and see if it is working. – HemChe Apr 18 '13 at 12:16