title: Handling dynamically generated ids in selenium webdriver
body: <p>I am trying to automate testing of a webpage that contains list of items. User input item is selected and is deleted. Here, I need to select VD2 and delete that item.</p>
  
  <pre><code>&lt;div id="virtual_domains-content"&gt;
      &lt;div class="columns"&gt;
          &lt;div class="left-column"&gt;
              &lt;h2&gt;Virtual Domains&lt;/h2&gt;
                  &lt;div class="search-row"&gt;
                      &lt;div class="box scrolling list-editable"&gt;
                          &lt;div id="virtual_domains-list" class="list-view"&gt;
                              &lt;div id="virtual_domains-list-11" class="list-item-view"&gt;
                                  &lt;div class="content"&gt; VD1 &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div id="virtual_domains-list-35" class="list-item-view"&gt;
                                  &lt;div class="content"&gt; VD2 &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  </code></pre>
  
  <p>The list that I get from the below code has only the first element - VD1. Second element is not captured. Can someone help me resolve the problem</p>
  
  <pre><code>List&lt;WebElement&gt; list = webdriver1.findElements(By.xpath("//*[starts-with(@id,'virtual_domains-list-')]"));
  for(WebElement option : list){
      System.out.println(option.getText());
      if(option.getText().equals("VD1")) {
          option.click();
          break;
      }
  </code></pre>