Selecting Multiple Items in Listbox

  1. String strURL;  
  2. strURL="URL";  
  3.   
  4. WebDriver firefoxDriver=new FirefoxDriver();    
  5. firefoxDriver.get(strURL);  
  6.   
  7. WebElement list1;    
  8. list1=firefoxDriver.findElement(By.name("lst"));    
  9.   
  10. List<WebElement> lstOptions=list1.findElements(By.tagName("option"));    
  11. list1.sendKeys(Keys.CONTROL);    
  12. lstOptions.get(0).click();//Selects the first option.    
  13. lstOptions.get(1).click();//Selects the second option.