Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99024

How can I select all the options in a drop down- Selenium Webdriver?

$
0
0
  • Currently working on Selenium WebDriver and using Java. If I have drop down name called Product..

  • In that drop down I have so many values (for ex:60). when executing the code I deselect all option then I selected which option I want because by default all values are selected in the HTML.. and it is working fine..

  • In the same way if I want to select all options at the same time.. How can I perform the action.

    <select id="productId" multiple="" style="width: 125px; display: none;" name="products[]"><option selected="" value="1020 ROUTER SERIES">1020 ROUTER SERIES</option><option selected="" value="1030 ROUTER SERIES">1030 ROUTER SERIES</option><option selected="" value="1040 ROUTER SERIES">1040 ROUTER SERIES</option><option selected="" value="1061 ROUTER">1061 ROUTER</option></select>

and so on..

Here is the sample code:

Log.info("Clicking on Product dropdown");JavascriptExecutor executor31 = (JavascriptExecutor)driver;executor31.executeScript("document.getElementById('ProductId').style.display='block';");Select select31 = new Select(driver.findElement(By.id("ProductId")));select31.deselectAll();select31.selectByVisibleText("1222");Thread.sleep(6000);JavascriptExecutor executor32 = (JavascriptExecutor)driver; executor32.executeScript("document.getElementById('ProductId').style.display='block';");Select select32 = new Select(driver.findElement(By.id("ProductId")));select32.selectByVisibleText("1020");

Viewing all articles
Browse latest Browse all 99024

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>