JS Testing Academy · QA Demo Site

Dropdowns & Select

Native selects, a multi-select, dependent dropdowns and – most importantly – a custom dropdown built from div elements, which is what most modern applications actually use.

Custom dropdown (not a <select>)

Built from div and li elements, with a search box – Select class will not work here, you have to click.

Practice tasks

  1. Select a role with the Select class and assert the output shows it.
  2. Select two skills in the multi-select and assert both are listed.
  3. Choose India and assert the city dropdown is enabled and contains Chennai.
  4. Change the country and assert the previously selected city is cleared.
  5. Open the custom dropdown, type play in its search box and assert only one option remains.
  6. Pick an option from the custom dropdown and assert the toggle text changes.
Sample automation code
Select role = new Select(driver.findElement(By.id("select-role")));
role.selectByValue("sdet");

Select skills = new Select(driver.findElement(By.id("select-skills")));
skills.selectByVisibleText("Java");
skills.selectByVisibleText("Playwright");

// custom dropdown - no Select class, just clicks
driver.findElement(By.id("custom-dropdown-toggle")).click();
driver.findElement(By.id("custom-dropdown-search")).sendKeys("play");
driver.findElement(By.xpath("//ul[@id='custom-dropdown-list']/li[not(@hidden)][1]")).click();
Assert.assertEquals(driver.findElement(By.id("custom-dropdown-value")).getText(), "Playwright");