Forms and inputs
BeginnerText fields, a native dropdown, radio buttons, checkboxes, a date picker, a textarea and validation messages.
Practice area
Tasks to automate
- Fill every field with valid data, submit, and assert that the result shows the name you typed.
- Submit the empty form and assert that all three error messages appear.
- Choose the country India by its visible text, then by its value.
- Select the gender radio Female and assert the others are not selected.
- Tick Automation and API testing but not Manual testing; assert each state.
- Set the date of birth to 15 August 1998 and assert the field value.
- Enter an invalid email (no @) and assert the email error, not the others.
Model solutions
Try the tasks first. These show one good way, not the only way.
Selenium (Java)
driver.get("https://qaknowledgehub.com/playground/forms");
driver.findElement(By.id("pg-name")).sendKeys("Asha Rao");
driver.findElement(By.id("pg-email")).sendKeys("[email protected]");
new Select(driver.findElement(By.id("pg-country"))).selectByVisibleText("India");
driver.findElement(By.id("pg-gender-female")).click();
driver.findElement(By.id("pg-int-automation")).click();
driver.findElement(By.id("pg-terms")).click();
driver.findElement(By.id("pg-submit")).click();
String result = new WebDriverWait(driver, Duration.ofSeconds(5))
.until(ExpectedConditions.visibilityOfElementLocated(By.id("pg-result"))).getText();
assertTrue(result.contains("Asha Rao"));
Playwright (TypeScript)
await page.goto('/playground/forms');
await page.locator('#pg-name').fill('Asha Rao');
await page.locator('#pg-email').fill('[email protected]');
await page.locator('#pg-country').selectOption({ label: 'India' });
await page.locator('#pg-gender-female').check();
await page.locator('#pg-int-automation').check();
await page.locator('#pg-terms').check();
await page.locator('#pg-submit').click();
await expect(page.locator('#pg-result')).toContainText('Asha Rao');
Element IDs on this page are stable and will not change. Nothing you do here is sent to a server.
