JS Testing Academy · QA Demo Site

Links

Links that work, links that open a new tab, and links that return different HTTP status codes.

Home (same tab)

Home (opens a new tab)

Link with a changing text

Status code links

These do not navigate – they call the status code API and show the response here.

Practice tasks

  1. Click the new-tab link, switch to the new window, assert its title, then switch back.
  2. Assert the href of the simple link without clicking it.
  3. Click each status button and assert the response text shows the expected status code.
  4. Reload the page and confirm the third link's text changes – locate it by id instead of by text.
Sample automation code
String parent = driver.getWindowHandle();
driver.findElement(By.id("new-tab-link")).click();
for (String handle : driver.getWindowHandles()) {
    if (!handle.equals(parent)) driver.switchTo().window(handle);
}
Assert.assertTrue(driver.getTitle().contains("QA Demo"));
driver.close();
driver.switchTo().window(parent);