Complete the code to locate the auto-complete input field by its ID.
WebElement input = driver.findElement(By.[1]("searchBox"));
The id locator is used to find the element with the exact ID 'searchBox'. This is the most direct and reliable way to locate the input field.
Complete the code to send the text 'Selenium' to the auto-complete input field.
input.[1]("Selenium");
The sendKeys method types the given text into the input field, simulating user input.
Fix the error in the code to wait until the auto-complete suggestions are visible.
new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.[1](By.className("suggestions")));
The visibilityOfElementLocated condition waits until the element is present and visible on the page, which is needed to interact with the suggestions.
Fill both blanks to select the first suggestion from the auto-complete list.
List<WebElement> suggestions = driver.findElements(By.[1]("suggestion-item")); suggestions.get([2]).click();
The suggestions are located by their class name 'suggestion-item'. The first suggestion is at index 0 in the list, so clicking it selects the first option.
Fill all three blanks to verify the selected suggestion text matches 'Selenium WebDriver'.
String selectedText = suggestions.get([1]).getText(); assertEquals([2], selectedText, "Suggestion text should be correct"); System.out.println("Selected: " + [3]);
The first suggestion is at index 0. We compare its text to the expected string 'Selenium WebDriver' using assertEquals. Then we print the selected text variable.