JS Testing Academy · QA Demo Site

Slider

A range input you can move with the keyboard or the mouse, and a custom slider that only responds to dragging.

Value: 25

Custom slider (drag only)

Value: 50

Practice tasks

  1. Move the range input to 75 with arrow keys and assert the displayed value.
  2. Set the range value with JavaScript and fire the input event, then assert the display updates.
  3. Drag the custom slider handle to the right and assert the value increases.
  4. Drag it fully to the left and assert the value becomes 0.
  5. Assert the aria-valuenow attribute matches the shown value.
Sample automation code
WebElement slider = driver.findElement(By.id("range-slider"));
for (int i = 0; i < 50; i++) { slider.sendKeys(Keys.ARROW_RIGHT); }
Assert.assertEquals(driver.findElement(By.id("range-value")).getText(), "75");

WebElement handle = driver.findElement(By.id("custom-slider-handle"));
new Actions(driver).dragAndDropBy(handle, 80, 0).perform();