In Selenium I am using UnSelectAll() on a normal select/Input element( Not multi select). What exception I can expect?

  • Not sure why you want to know about an exception? What is the scenario that you're testing? Commented Oct 6, 2016 at 9:39
  • Just try and write it down? Commented Oct 6, 2016 at 10:18

2 Answers 2


I am just putting code from select API of selenium.support.ui. The code is self explanatory

public void deselectAll() {
if (!isMultiple()) {
  throw new UnsupportedOperationException(
      "You may only deselect all options of a multi-select");

for (WebElement option : getOptions()) {
  setSelected(option, false);

Here isMultiple is defined in constructor of Select class as mentioned below

private final boolean isMulti;
public Select(WebElement element) {
String value = element.getAttribute("multiple");

// The atoms normalize the returned value, but check for "false"
isMulti = (value != null && !"false".equals(value));

public boolean isMultiple() {
   return isMulti;

De-select all checkboxes -

WebElement parent = driver.findElement(By.xpath("<enter parent xpath>"));  
List<WebElement> children = parent.findElements(By.cssSelector("input:checked[type='checkbox']"));  
for (int i = 0; i < children.size(); i++) { children.get(i).click(); }

See this for more help

  • But I would like to know about the the excepted exception when I use deselect all ( actually deselectall is for multiselect item) But If my object is not a multi seelect item what exception i can expect?
    Commented Oct 6, 2016 at 7:44
  • Why you are focusing on which exception will occur? Share scenario where you need help. Why looking desperately to fail and observe exception? Commented Oct 6, 2016 at 8:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.