What Should Not Be a UI Test

Move Checks Down

CheckBest levelWhy
Coupon SAVE10 gives 10% off with a ₹500 capunit / APIpure calculation; many combinations
Registration rejects 15 invalid emailsAPI (one UI test for the error message)validation lives in the backend
Product search returns correct resultsAPIdata and ranking, not layout
User can log in, search, add to cart and payUIthe real user journey across pages
Error message is shown in red under the fieldUI (or visual testing)only the browser renders it
Sort by price works on 40 productsAPI for the order, one UI test for the controlavoid reading 40 cards each time

Checking API and UI Agree

Example

A common hybrid check: read prices from the API (fast, exact) and from the UI (formatted text), then compare. Here both lists are fixed values:

import java.util.*;

public class Main {
    static double parseRupees(String text) {
        return Double.parseDouble(text.replace("₹", "").replace(",", "").trim());
    }

    public static void main(String[] args) {
        Map<String, Double> apiPrices = new LinkedHashMap<>();
        apiPrices.put("Boat Rockerz 450", 1499.0);
        apiPrices.put("Sony WH-CH520", 4490.0);
        apiPrices.put("JBL Tune 510BT", 3299.0);

        Map<String, String> uiPrices = Map.of(
                "Boat Rockerz 450", "₹1,499",
                "Sony WH-CH520", "₹4,490",
                "JBL Tune 510BT", "₹3,499");

        int mismatches = 0;
        for (var e : apiPrices.entrySet()) {
            double ui = parseRupees(uiPrices.get(e.getKey()));
            boolean ok = ui == e.getValue();
            if (!ok) mismatches++;
            System.out.printf("%-17s api=%7.2f ui=%7.2f %s%n", e.getKey(), e.getValue(), ui, ok ? "OK" : "MISMATCH");
        }
        System.out.println(mismatches == 0 ? "PASS" : "FAIL: " + mismatches + " price(s) differ");
    }
}

Output

Boat Rockerz 450  api=1499.00 ui=1499.00 OK
Sony WH-CH520     api=4490.00 ui=4490.00 OK
JBL Tune 510BT    api=3299.00 ui=3499.00 MISMATCH
FAIL: 1 price(s) differ