liveBook · Manning

User-interaction testing

As explained in Django in Action

UI testing evaluates software by interacting with its user interface, often through tools that simulate user actions.

User-interaction testing evaluates software through its user interface, using tools that act like a person: opening pages, finding controls, clicking links, entering data, and checking what appears. It sits at the top of the testing pyramid. The boundary between UI testing and behavioral testing can be blurry because proving a feature works may require interacting with the interface. section 8.1.1 section 8.10

Use UI tests selectively because each test exercises the entire web stack:

  • A browser enters information, sends a request to the server, triggers server and database work, receives a result, and displays it. section 8.1.1
  • This full round trip makes UI tests slower and more expensive than unit, integration, or behavioral tests, especially when many input variations are required. section 8.1.1 section 8.10
  • Keep most tests lower in the hierarchy and reserve UI tests for behavior that genuinely needs browser-level verification. section 8.1.1 section 8.10

Driving a Django page with Selenium

Selenium integrates with a web browser and offers two approaches. Click-and-record captures actions for playback and is quick to learn, but small page changes can make recordings fragile. API-based tests search HTML elements and interact with them in code; assigning IDs to tags makes selectors easier to maintain. In Django, TestCase calls views directly and does not execute JavaScript. Use LiveServerTestCase when the test must see the page as a browser does; use StaticLiveServerTestCase when CSS and JavaScript also need serving. Create test data in setUp(), then call Selenium from the test methods. section 8.7.1 section 8.7.1

Figure 8.1 Hierarchy of testing categories
figure

Use the testing hierarchy to place user-interaction testing above unit, integration, and behavioral testing, then weigh its broad coverage against its cost. section 8.1.1

How Django in Action covers it

How deep it goes
Explains browser round trips and Django server requirements, but defers comprehensive Selenium instruction.
Examples
Uses shipping-cost forms, browser-entered addresses, Selenium selectors, and Django live-server test classes.
What it assumes
Assumes basic Django testing and HTML knowledge while explaining browser automation and live-server requirements.
What you can do after
Apply it via Selenium and Django live-server test classes to verify browser-visible behavior.
How it connects
Connects UI testing with behavioral testing, integration testing, unit testing, Selenium, and Django TestCase.

Also explained in

Compare how 2 books explain user-interaction testing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Django in Action. The section links point to the parts of the book it draws on.