Anyone please explain various methods used to de-select options of a dropdown in Webdriver

0 votes
Anyone please explain various methods used to de-select options of a dropdown in Webdriver
Jul 14 in Selenium by Natasha
27 views

1 answer to this question.

0 votes

Hey Natasha, following methods are used to deSelect an option/options of a dropdown in Selenium Webdriver:

  1. deselectByVisibleText(): This method removes the selected item from list for particular option:

    • Select dropdown = new Select(driver.findElement(By.id("Month"))); 
      dropdown.deselectByText("June");
  2. deselectByValue(): Deselect option from list by using value of particular option:

    • Select dropdown = new Select(driver.findElement(By.id("Month"))); 
      dropdown.deselectByValue("june");
  3. deselectByIndex(): This method removes the selection by index value of the option. Index values of the list are always in integer:

    • Select dropdown = new Select(driver.findElement(By.id("Month"))); 
      dropdown.deselectByIndex(5);
  4. deselectAll(): Method is able to Deselect all Selected options from Multi-Select Dropdown:

    • Select dropdown = new Select(driver.findElement(By.id("Month"))); 
      dropdown.deselectAll();
answered Jul 15 by Abha
• 25,740 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
798 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,038 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
743 views
0 votes
1 answer