title: Parameterizing select option using selenium
body: <p>I have a scenario in which i have to select an industry and based on the industry selected i have to select a category and based on category i have to choose the distributor.</p>
  
  <p>Although i was able to select the industry and category i was not able to select my distributor. that i have passed in the parameter.</p>
  
  <p>My junit code is</p>
  
  <pre><code>@RunWith(Parameterized.class)
       public class test2 {
  
         WebDriver driver;
         private String email; 
         private String pdesc;
         private String pass;
         private String ind;
         private String cat;
         private String dis;
         private String pname;
         private String at1;
         private String atv1;
         private String img;
  
         public test2(String emailid, String password,String industry, String cate,  
                          String dist, String productname, String productdesc, 
                               String attname, String attvalue,String uploadimg ){
          this.email = emailid;
          this.pass = password;
          this.ind = industry;
          this.cat = cate;
          this.dis =dist;
          this.pname = productname;
          this.pdesc = productdesc;
          this.at1 = attname;
          this.atv1 = attvalue;
          this.img = uploadimg;
            }
  
  
       @Parameters
       public static Collection&lt;Object[]&gt;data(){     
       Object[][] data = new Object[][] 
       { {"user1","user1","Industry1","category1","distributor","product name",
       "product description","price","Rs. 1,50,000","Lighthouse.jpg" }  };
  
        return Arrays.asList(data);
       }
  
      @Before
      public void setUp(){
      driver = new FirefoxDriver();
      driver.manage().window().maximize();
      }
  
      @After
      public void tearDown(){
      driver.quit();
      }
  
  
  @Test
      public void testFindElements()throws Exception{
      driver.get("http://domain.com");
      Thread.sleep(500);
  
    *****Login with username and password******
  
      WebElement em = driver.findElement(By.id("email_id"));
      em.sendKeys(email);
      WebElement pwd = driver.findElement(By.id("password"));
      pwd.sendKeys(pass);
      Thread.sleep(500);
      driver.findElement(By.xpath("//button[@type='submit']")).click();
      Thread.sleep(500);
  
      *******NAVIGATE TO ADD PRODUCT PAGE*******
  
      WebElement hover = driver.findElement(By.className("dropdown-toggle"));
      Actions builder = new Actions(driver);
      builder.moveToElement(hover).build().perform();
      driver .findElement(By.linkText("Add")).click();
  
      ****SELECTING THE INDUSTRY****
      new Select(driver.findElement(By.id("ProductIndustryId"))).selectByVisibleText(ind);   
  
      *****SELECTING THE CATEGORY*********
      WebElement category = driver.findElement(By.id("ProductCategoryId"));
      category.sendKeys(cat);
  
      ****CLICK ON SELECT DISTRIBUTOR RADIO BUTTON*****
      driver.findElement(By.cssSelector("div.radio-list &gt; label")).click();
      driver.findElement(By.id("seldist")).click();
      Thread.sleep(500);
      Thread.sleep(500);
  
      ****SELECTING MY DISTRIBUTOR(JOHN)*****
      driver.findElement
     (By.xpath("//html/body/div[3]/div[2]/div/div/form/div[3]/div/div/div/div/div[5]/div/div/div/select/option")).sendKeys(dis);
  
      ****ADDING PRODUCT DETAILS****
  
      WebElement prodname = driver.findElement(By.cssSelector("div.col-md-9 &gt; 
      input[name=\"data[Product][product_name]\"]"));
      prodname.sendKeys(pname);
  
      WebElement pd = driver.findElement(By.cssSelector("textarea[name=\"data[Product]
      [description] rows=\"]"));
      pd.sendKeys(pdesc);
  
      WebElement a1 = driver.findElement(By.name("data[Attribute][0][display_name]"));
      a1.sendKeys(at1);
  
      WebElement av1 = driver.findElement(By.name("data[Attribute][0][product_value]"));
      av1.sendKeys(atv1);
  
      driver.findElement(By.name("data[Product][product_image]")).click();
      WebElement upload = driver.findElement(By.name("data[Product][product_image]"));
      upload.sendKeys(img);
  
      driver.findElement(By.cssSelector("div.col-md-offset-3.col-md-9 &gt; 
                                  button.btn.green")).click();
  
      driver.findElement(By.linkText("Done")).click();
         } 
      }
  
  
   &lt;select name="data[Product][industry_id]" class="form-control" id="ProductIndustryId"&gt;
   &lt;option value=""&gt;-Select Industry-&lt;/option&gt;
   &lt;option value="1"&gt;Textiles&lt;/option&gt;
   &lt;option value="2"&gt;Automobiles&lt;/option&gt;
   &lt;option value="10"&gt;Home Improvement&lt;/option&gt;
   &lt;/select&gt;
   &lt;select name="data[Product][category_id]" class="form-control" id="ProductCategoryId"&gt;
   &lt;/select&gt;
   &lt;label&gt;
   &lt;div class="radio" id="uniform-seldist"&gt;&lt;span class="checked"&gt;&lt;input type="radio" 
   name="data[Product][user_type]" id="seldist" value="A" style="display:inline"&gt;
   &lt;/span&gt;
   &lt;/div&gt;
   Select distributor&lt;/label&gt;
   &lt;div class="input select"&gt;
   &lt;input type="hidden" name="data[Product][distributor_id]" value=""     
      id="ProductDistributorId_"&gt;
   &lt;select name="data[Product][distributor_id][]" class="form-control" multiple="multiple" 
      id="ProductDistributorId"&gt;
   &lt;/select&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Note: I was not able to select the Distributor passed in the parameter. But selects other distributor. Ex: list of distributor is john, Dennis, Katie.</p>
  
  <p>I have passed <strong>john</strong> to be my distributor but it selects <strong>katie</strong> </p>