Complete the code to open the browser and navigate to the form page.
WebDriver driver = new ChromeDriver(); driver.[1]("https://example.com/form");
The get method opens the given URL in the browser.
Complete the code to find the username input field by its name attribute.
WebElement username = driver.findElement(By.[1]("username"));
The name locator finds elements by their name attribute, which is common for form inputs.
Fix the error in the code to enter text into the password field.
WebElement password = driver.findElement(By.id("password")); password.[1]("mySecret123");
The sendKeys method types text into input fields.
Fill both blanks to submit the form and wait for the success message.
driver.findElement(By.id("submitBtn")).[1](); new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.[2](By.id("successMsg")));
Clicking the submit button sends the form. Then waiting for presenceOfElementLocated ensures the success message appears.
Fill all three blanks to verify the success message text after form submission.
String message = driver.findElement(By.id([1])).getText(); assertEquals([2], message, [3]); driver.quit();
The element with id "successMsg" contains the message. We check it equals the expected success text. Finally, we close the browser.