liveBook · Manning

Playwright

As explained in Build Financial Software with Generative AI (From Scratch)

Playwright is a cross-browser automation and testing tool for web applications that supports multiple programming languages and operating systems.

Playwright is a cross-browser, cross-platform, cross-language tool for end-to-end testing web applications. It validates an integrated MVP after APIs, parsing, databases, and dashboards work together. section 7.0 section 7.9

A practical Python workflow includes:

  • Install pytest-playwright with pip, then run playwright install to install the required browser extensions. section 7.9
  • Explore interactions in an interactive Python console with a visible browser by launching Chromium with headless=False. section 7.9
  • Navigate to pages, locate controls, fill fields, click buttons, wait for rendered elements, and assert URLs, identifiers, text, visibility, and responses. section 7.9 section 9.2.4
  • Use get_by_role for accessible element selection; its ARIA-based approach can support pages compatible with assistive-technology standards. section 7.9

Testing an ACH search

An integration test clears the database, loads an ACH file, opens the search page, enters “sally saver,” waits for the transaction-search response, checks for HTTP 200, verifies the visible result, and captures a screenshot. Pytest fixtures can display the browser and isolate each page with a fresh context. section 9.2.4

Listing 9.19 Playwright testing
def test_dashboard(page: Page):
    page.goto("http://localhost:3000/search") #1
    page.expect_navigation(wait_until="load")  #2
    expect(page).to_have_url("http://localhost:3000/search") #2
    search_criteria = page.get_by_role("textbox") #3
    search_criteria.fill("sally saver")  #4
    search_button = page.locator("#searchbtn") #4
    with page.expect_response("**/files/transactions/search*") #5
➥ as response_info:  #6
        search_button.click()  #6

    response = response_info.value #6
    assert response.status == 200 #6
    search_result = page.locator('div[title="Sally Saver"]') #7
    expect(search_result).to_be_visible()  #8
    page.screenshot(path="screenshots/search_results.png") #8

The listing provides a compact reference for navigation, role-based input, response waiting, status checking, visibility assertions, and screenshots. section 9.2.4

How Build Financial Software with Generative AI (From Scratch) covers it

How deep it goes
Demonstrates installation, interactive exploration, selectors, waits, assertions, screenshots, fixtures, and API-response checks.
Examples
Exercises login validation, exception-message rendering, ACH searching, response checking, browser fixtures, and screenshots.
What it assumes
Assumes Python, pytest, web pages, and the tested application exist; teaches Playwright setup and browser interactions directly.
What you can do after
Diagnose/debug with it by reproducing browser interactions, checking rendered states and responses, and capturing screenshots.
How it connects
Connects end-to-end testing with pytest, Python, TDD, BDD, Jest, integration testing, and ARIA.

Also explained in

Compare how 2 books explain Playwright →

Related concepts

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