Amirdha Amirdha -3 years ago 71
Java Question

how to select element in multi select box in selenium webdriver

Currently working on Selenium WebDriver and using Java.. I want to know to select values in Multi-select box. The options are already selected.. If i want to select any two or more option. how can perform the action.

The HTML is follows:

<select id="swpacksId" multiple="" style="width: 125px; display: none;" name="swPacks[]">
<option selected="" value="ADVIP">ADVIP</option>
<option selected="" value="ADVLEG">ADVLEG</option>
<option selected="" value="ADVSEC">ADVSEC</option>
<option selected="" value="Boot">Boot</option>
<option selected="" value="H323">H323</option>
<option selected="" value="IBC">IBC</option>
<option selected="" value="MULTI">MULTI</option>
<option selected="" value="None">None</option>

enter image description here

Answer Source

In a function pass a list of values use any delimiter lets say comma as a delimiter,

public static void selectMultipelValues(String multipleVals){

   String multipleSel[] = multipleVals.split(",");

   for (String valueToBeSelected : multipleSel) {

new Select(driver.findElement(;




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download