Skip to main content
Visual Testing · Stack

Visual Testing for Django with Robot Framework

Visual testing for Django with Robot Framework adds screenshot comparisons to the acceptance tests Python teams already write in Robot Framework, with either the Browser library or SeleniumLibrary. The wopee_rf library adds keywords such as Track Fullpage, or a listener that takes screenshots after chosen keywords without changing the tests, and Wopee.io compares each screenshot with the approved baseline so you review template and layout changes in Wopee Commander.

Why visual testing Django with Robot Framework is hard

Django teams that test in Python often choose Robot Framework for browser-level acceptance tests, because the keyword syntax is readable for testers and the libraries cover both Playwright-based Browser and Selenium. Neither library compares screenshots: Take Screenshot and Capture Page Screenshot save images into the log for debugging, and spotting a regression still means opening them by eye. Django apps make that painful at scale, since many pages extend one base.html, so a change to a shared block, a static CSS file, or the admin theme alters dozens of pages at once. Generated documents add another blind spot: invoices or reports rendered as PDF are checked by opening them, if at all. Adding visual checks to a large suite by editing every test is rarely approved.

How Wopee.io adds visual checks to Robot Framework

wopee_rf gives Robot Framework suites two ways in. With keywords, import wopee_rf.Standalone after your browser library and add Start Suite, Start Scenario, Track Fullpage or Track Viewport, and Stop Scenario in the teardown; every argument is named, such as step_name=Dashboard. With the listener, run the existing suite unchanged with --listener wopee_rf.Listener and list the keywords to screenshot after in WOPEE_TRACKED_KEYWORDS, for example Browser.Wait For Elements State. Both work with the Browser library and SeleniumLibrary; set WOPEE_DRIVER_LIBRARY to match and WOPEE_SCREENSHOT_VALIDATION_ENABLED=true, or nothing is sent. The Track keyword compares any PNG you pass in as base64, so a PDF rendered to an image can be checked too. A visual difference leaves the test green unless you set WOPEE_ENABLE_SOFT_ASSERT=false, and WOPEE_PIXEL_TO_PIXEL_DIFF_TOLERANCE=0.1 absorbs font-smoothing noise. When a base.html change shifts every page, the review is one session in Wopee Commander. For coverage beyond your own suites, see AI testing for Django and AI regression testing. Setup: Robot Framework guide and configuration and listener.

How to get started

  1. 1
    Create a Wopee.io project with the test framework set to Robot Framework and copy WOPEE_API_URL, WOPEE_PROJECT_UUID, and a new WOPEE_API_KEY into .env.
  2. 2
    Install with pip install "wopee_rf>=2.7.2" robotframework robotframework-browser (or robotframework-seleniumlibrary) on Python 3.11 or newer.
  3. 3
    Add WOPEE_SCREENSHOT_VALIDATION_ENABLED=true and WOPEE_DRIVER_LIBRARY=BrowserLibrary (or SeleniumLibrary) to .env.
  4. 4
    Either add Start Suite, Start Scenario, Track Fullpage, and Stop Scenario keywords to your tests, or run the suite with --listener wopee_rf.Listener and WOPEE_TRACKED_KEYWORDS.
  5. 5
    Run robot against runserver or staging, approve the first screenshots in Commander, and review unresolved steps on later runs.

Example: a Robot Framework test with visual checks

tests/admin_visual.robot
*** Settings ***
Library Browser
Library wopee_rf.Standalone dot_env_path=.env

Test Setup New Page http://localhost:8000/admin/login/
Test Teardown Stop Scenario

*** Variables ***
${SUITE} Django admin ${{datetime.datetime.now().strftime('%Y-%m-%d %H:%M')}}

*** Test Cases ***
Admin Login And Order List
Start Scenario scenario_name=Django admin: login and orders suite_name=${SUITE}
${login}= Track Fullpage step_name=Admin login

Fill Text id=id_username %{ADMIN_USER}
Fill Text id=id_password %{ADMIN_PASSWORD}
Click css=input[type=submit]
Go To http://localhost:8000/admin/shop/order/
Wait For Elements State id=result_list visible

${orders}= Track Fullpage step_name=Order list
Log To Console \nLogin: ${login.status} | Orders: ${orders.status}

From manual effort to AI-assisted testing

More automation. Less maintenance. Faster review.

Screenshots in the Robot log

Visual comparison
Opened by eye
Changes to existing tests
Screenshot keywords added by hand
Browser and Selenium
Both
Generated PDFs
Opened by hand

Community image-compare libraries

Visual comparison
Local comparison, baselines on disk
Changes to existing tests
Keywords added to each test
Browser and Selenium
Depends on the library
Generated PDFs
Some support documents
Wopee.ioWopee.io
AI testing
Visual comparison
Baselines in Wopee.io, review in Commander
Changes to existing tests
None with the listener, or Track keywords
Browser and Selenium
Browser library and SeleniumLibrary
Generated PDFs
Track keyword compares any PNG

Add visual checks to your Robot Framework tests

Keep your tests, add a few track calls, and review every visual change in one place.

Frequently asked questions

Yes. Run the suite with --listener wopee_rf.Listener and set WOPEE_TRACKED_KEYWORDS to the keywords after which a screenshot should be taken, written as Library.Keyword and separated by semicolons without spaces.

Usually WOPEE_SCREENSHOT_VALIDATION_ENABLED=true or WOPEE_DRIVER_LIBRARY is missing, or robot runs from a folder where .env is not found. The track keywords then return None and send nothing.

Yes. Set WOPEE_DRIVER_LIBRARY=SeleniumLibrary and import SeleniumLibrary instead of Browser. The Wopee.io keywords and the listener work the same way with both.