Complete the code to open a browser and navigate to a URL.
WebDriver driver = new ChromeDriver(); driver.[1]("https://example.com");
The get method loads a new web page in the current browser window.
Complete the code to find a button by its ID and click it.
WebElement button = driver.findElement(By.[1]("submitBtn")); button.click();
The By.id locator finds elements by their unique ID attribute.
Fix the error in the code to wait until an element is visible before clicking.
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10)); wait.until(ExpectedConditions.[1](By.id("loginBtn"))); driver.findElement(By.id("loginBtn")).click();
presenceOfElementLocated may cause errors if element is hidden.visibilityOfElementLocated waits until the element is visible on the page.
Fill the blank to create a test that asserts the page title contains a word.
String title = driver.getTitle(); assertTrue(title.[1]("Example"));
The contains method checks if the title includes the given word.
Fill both blanks to create a map of element texts filtered by length.
Map<String, Integer> lengths = elements.stream() .filter(e -> e.getText().length() [1] 3) .collect(Collectors.toMap(e -> e.getText(), e -> e.getText().[2]())); lengths.forEach((k, v) -> System.out.println(k + ": " + v));
The filter keeps texts longer than 3 characters. The map stores text and its length.
