title: Selenium: searching children of a By locator in Java
body: <p>I have an enum list of By locators for WebElements on a page. I want to be able to select a specific option of a select box using a combination of the enum as well as additional information of the value of the option I wish to select. Is there any way to do this? I notice that the <code>By</code> class also has the method <code>findElement(searchContext)</code>. Could I use this as something along the lines of:</p>
  
  <pre><code>public enum Dictionary {
  
      TYPE                        (By.id("vehType")),
      PROVINCE                    (By.id("provId")),
      TERRITORY                   (By.id("territoryId")),
      STAT_CODE                   (By.id("statCodeId")),
      CLASS                       (By.id("class1Id"));
  
      private final By locator;
  
      private DetailVehicleDictionary (By value) {
          this.locator = value;
      }
  
      public By getLocation() {
          return this.locator;
      }
  }
  </code></pre>
  
  <p>And then if CLASS is a select box with HTML of:</p>
  
  <pre><code>&lt;select id="class1Id" name="select_box"&gt;
      &lt;option value="1"/&gt;
      &lt;option value="2"/&gt;
      &lt;option value="3"/&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Can I do something along the lines of:</p>
  
  <pre><code>WebElement specificValue = driver.findElement(Dictionary.CLASS.getLocation().findElement(By.cssSelector("option[value=2]"));
  </code></pre>
  
  <p>I need to have access to the actual element so that I can wait for the value to be present in the DOM. I plan on implementing this in a wait command such as:</p>
  
  <pre><code>wait.until(ExpectedConditions.presenceOfElementLocated(specificValue));
  </code></pre>