JS Testing Academy · QA Demo Site

Buttons

Click, double click and right click – each one writes its own message, so you can prove which action happened.

The last button gets a new random id on every page load – practise locating it by data-testid or by its text instead.

Practice tasks

  1. Click the first button and assert its message appears.
  2. Double click the second button using Actions / dblclick() and assert only the double-click message appears.
  3. Right click the third button and assert the right-click message appears.
  4. Reload the page twice and confirm the fourth button's id changes – then write a locator that still works.
Sample automation code
Actions actions = new Actions(driver);
driver.findElement(By.id("single-click-btn")).click();
Assert.assertTrue(driver.findElement(By.id("single-click-message")).isDisplayed());

actions.doubleClick(driver.findElement(By.id("double-click-btn"))).perform();
actions.contextClick(driver.findElement(By.id("right-click-btn"))).perform();

// changing id - locate by a stable attribute instead
driver.findElement(By.cssSelector("[data-testid='dynamic-id']")).click();