JS Testing Academy · QA Demo Site

Selectable

Click items to select them, Ctrl/Cmd click to select several. There is a list and a grid – the grid is the harder one to assert on.

List

  • Manual Testing
  • Selenium
  • Playwright
  • API Testing

Grid

1
2
3
4
5
6
7
8
9

Practice tasks

  1. Click one list item and assert it gets the selected class.
  2. Ctrl/Cmd click a second item and assert both are selected.
  3. Click a third item without Ctrl and assert only that one stays selected.
  4. Select three grid cells and assert the output lists exactly those numbers.
  5. Click a selected item again and assert it is deselected.
Sample automation code
WebElement item = driver.findElement(By.cssSelector("#selectable-list li:nth-child(2)"));
item.click();
Assert.assertTrue(item.getAttribute("class").contains("selected"));

new Actions(driver).keyDown(Keys.CONTROL)
    .click(driver.findElement(By.cssSelector("#selectable-list li:nth-child(3)")))
    .keyUp(Keys.CONTROL).perform();
Assert.assertEquals(driver.findElements(By.cssSelector("#selectable-list li.selected")).size(), 2);