title: Selenium WebDriver: How to select a value in a span dropdown?
body: <p>I'm trying to get my Selenium script to click on a value within a dropdown menu. However I am having trouble getting any action to happen within the dropdown after I initially clicked it. I have looked online and can only find answers if the dropdown was 'Select.'</p>
  
  <p>Here is the HTML for the dropdown:</p>
  
  <pre><code>&lt;span class="select2-selection__rendered" title="1st item"
        id="select2-id_template_or_inspection-container"&gt;
  &lt;/span&gt;
  </code></pre>
  
  <p>Here is the code snippet where I click on the dropdown:</p>
  
  <pre><code>//Choose a Template from Dropdown
  
  WebElement dropdownBtn = webDriver.findElement(
              By.id("select2-id_template_or_inspection-container"));
  
  dropdownBtn.click();
  </code></pre>
  
  <p>Here is the code snippet where I try to click on a value in the dropdown:</p>
  
  <pre><code>WebElement dropdownItemBtn = webDriver
        .findElement(By.id("select2-id_template_or_inspection-result-hlwt-tmpl-2583"));
  dropdownItemBtn.click();
  </code></pre>
  
  <p>However the IDs for the values in the dropdown change each time the page is reloaded. </p>
  
  <p>I appreciate the help!</p>