<select id=”SelectedCustomerRoleIds” multiple=”multiple” name=”SelectedCustomerRoleIds” data-role=”multiselect” aria-disabled=”false” style=”display: none;” xpath=”1″>
<option value=”1″>Administrators</option>
<option value=”2″>Forum Moderators</option>
<option value=”4″>Guests</option>
<option value=”3″ selected=”” style=””>Registered</option>
<option value=”5″>Vendors</option></select>
I have tried the following code to deselect option 3 – Registered and select option 4 – Guests.
WebElement element= driver.findElement(By.id(“SelectedCustomerRoleIds”)):
Select select = new Select(element): select.deselectByValue(“3”):
select.selectByValue(“4”)
Source: Read More