how to select element in multi select box in selenium webdriver

0
0

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>
</select>

enter image description here

  • You must to post comments
0
0

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(By.id(propId))).selectByVisibleText(valueToBeSelected);
driver
.findElement(By.id(ddObj)).sendKeys(Keys.CONTROL);
}
}
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website