title: How to drag and drop in selenium when there are multiple elements
body: <p>The following code is not working. The reportDataFields displays a list of items(for ex abc, abd, abe) and I want to select abc and drop into the target. It does not fisplay any error message either.</p>
  
  <pre><code>Actions action = new Actions(driver);
  List&lt;WebElement&gt; reportFields = driver.findElements(By.className("reportDataFields"));
  WebElement target = driver.findElement(By.id("rptDataSections"));
  
  for (int i = 0; i &lt; reportFields.size(); i++) {
  
      if (reportFields.get(i).getText().equals(Section)) {
          action.dragAndDrop(reportFields.get(i), target).release().build().perform();
          try {
              Thread.sleep(1000);
          } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
      }
  }
  </code></pre>