title: how to write script for same procedure for all same class element?
body: <p>I am new in selenium webdriver with java. I have <code>&lt;a class="row-title"&gt;</code> property up to 21 web element.I want to do code in loop so i can merge java selenium code in to small, currently i have to write same script for all 21 test. Ex.</p>
  
  <pre><code>&lt;a class="row-title"&gt;1&lt;/a&gt;&gt;
  ........
  ........
  &lt;a class="row-tilte"&gt;21&lt;/a&gt;.
  
  also i have to do same clicking and update procedure up to 1 to 21 
  
  
  package Dev_admin;
  import java.nio.channels.SelectableChannel;
  import java.util.concurrent.TimeUnit;
  import org.openqa.selenium.By;
  import org.openqa.selenium.JavascriptExecutor;
  import org.openqa.selenium.Keys;
  import org.openqa.selenium.WebElement;
  public class present extends login{
  @Test(priority = 1)
  public void update1() {
      driver.findElement(By.xpath(".//*[@id='post-1217']/td[1]/strong/a")).click();
      WebDriverWait wait = new WebDriverWait(driver, 20);
      WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//*[@id='menu-posts-presentation']/a/div[3]")));
      element.click();
          }
  @Test(priority = 2)
  public void update2(){
      driver.findElement(By.xpath(".//*[@id='post-1139']/td[1]/strong/a")).click();
      WebDriverWait wait = new WebDriverWait(driver, 20);
      WebElement element = 
      wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//* 
      [@id='menu-posts-presentation']/a/div[3]")));
      element.click();        
  
  
  //if i am using class name instead of x path , then how to do same procedure 
  in loop so my code became so small or merged..
  
  @Test(priority = 1)
      public void update1() {
      driver.findElement(By.className("row-title")).click();
      WebDriverWait wait = new WebDriverWait(driver, 20);
      WebElement element = 
      wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//* 
      [@id='menu-posts-presentation']/a/div[3]"))); 
      element.click();
          }
  
  @Test(priority = 2)
     public void update2(){
     driver.findElement(By.className("row-title")).click();
      WebDriverWait wait = new WebDriverWait(driver, 20);
      WebElement element = 
      wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//* 
      [@id='menu-posts-presentation']/a/div[3]")));
      element.click();        
  }
  </code></pre>