liveBook · Manning

Automated UI check

As explained in Software Testing with Generative AI

An automated UI check is a programmatic test that interacts with a user interface and verifies expected behavior or state.

An automated UI check programmatically creates application state, interacts with a user interface, and verifies expected behavior. Its many moving parts include the automation framework, UI actions, state setup, and assertions. section 7.1

Build checks incrementally rather than requesting an entire implementation from an AI tool:

  • Configure the framework and driver used by the automation environment. section 7.1
  • Create the required state, locate UI elements, perform interactions, and assert product-specific expectations. section 7.1
  • Supply system context to AI tools and verify generated code before integrating it. section 7.1

Login validation

A Selenium and Java check opens a login page, finds username and password fields, enters credentials, and validates the resulting behavior. Product-specific drivers, URLs, selectors, page objects, and assertions still require adaptation. section 7.1

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
 
public class LoginTest {
    public static void main(String[] args) {
        // Set the path to the chromedriver executable
        System.setProperty("webdriver.chrome.driver", "path/to/
        ➥ chromedriver");
 
        // Create an instance of ChromeDriver
        WebDriver driver = new ChromeDriver();
 
        // Open the application login page
        driver.get("https://example.com/login");
 
        // Find the username and password input fields
        WebElement usernameField =
        ➥ driver.findElement(By.id("username"));
        WebElement passwordField =
        ➥ driver.findElement(By.id("password"));
 
        // Enter the username and password
        usernameField.sendKeys("your-username");
        passwordField.sendKeys("your-password");
 
        // Submit the login form
        driver.findElement(By.id("login-button")).click();
 
        // Wait for the page to load
        // You can use an explicit wait here to ensure the page is 
        ➥ fully loaded
 
        // Verify the login success by checking for a specific 
        ➥ element on the next page
        WebElement welcomeMessage = driver.findElement(By.xpath("//
        ➥ h1[contains(text(),'Welcome')]"));
        if (welcomeMessage.isDisplayed()) {
            System.out.println("Login successful!");
        } else {
            System.out.println("Login failed!");
        }
 
        // Close the browser
        driver.quit();
    }
}

Inspect the representative Selenium and Java login-check listing. section 7.1

How Software Testing with Generative AI covers it

How deep it goes
Explains check components and integration changes, but stops short of a complete product-ready implementation.
Examples
Uses a Selenium login test with browser setup, credentials, element selectors, and validation.
What it assumes
Assumes familiarity with UI automation frameworks and product context while demonstrating the login workflow concretely.
What you can do after
Apply it via Selenium and Java while adapting drivers, selectors, page objects, and assertions to the product.
How it connects
Connects UI automation with Selenium, Java, Page Object, assertions, and AI coding tools.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Testing with Generative AI. The section links point to the parts of the book it draws on.