Skip to content

Commit 1db353a

Browse files
authored
Prompt enhancements (#6)
* Revise instructions for UI screenshot validation Updated UI validation instructions for clarity and detail. * Add version 1.3.0 release notes to CHANGES.txt * Add project URLs to setup.py * Update assertions in test_library.py for accuracy * Add coverage for AIVision in pytest command * Update assertion message in test for AI response * Update assertions in test_lib.py for accuracy * Update test_lib.py * Fix assertion message in test_library.py * Update assertion for instructions in test_library.py * Update assertion for instructions in test_lib.py
1 parent dbada96 commit 1db353a

6 files changed

Lines changed: 62 additions & 10 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ jobs:
130130
131131
# Run tests with multiple output formats
132132
python -m pytest unittests/ \
133-
--cov=epg_grabber \
133+
--cov=AIVision \
134134
--cov-report=xml \
135135
--cov-report=html \
136136
--cov-report=term-missing \

AIVision/library.py

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,57 @@ def verify_screenshot_matches_look_and_feel_template(self, screenshot_path, temp
162162
except Exception as e:
163163
logger.warn(f"Could not create combined image: {e}")
164164

165-
instructions = """First image is showing actual application view.
166-
Second image is reference design template.
167-
Verify screenshot matches look and feel template. Pay attention to details, design is important.
168-
Make sure to check also all the visible logos, titles, labels, spelling, texts, links, menus, banners
169-
and any available graphics. Always doublecheck the reference image in case you think some
170-
text, label, logo or element is overlapping or containing typo.
165+
instructions = """
166+
First image is the actual application screenshot.
167+
Second image is the reference design/template screenshot.
168+
169+
Compare the actual screenshot against the reference screenshot as a visual UI/template validation.
170+
171+
Primary goal:
172+
Verify that the actual page matches the reference page in layout, visual structure, branding, and look-and-feel.
173+
174+
Check carefully:
175+
- Overall page structure and visual hierarchy
176+
- Header, navigation, menu icons, logos, brand marks, and banners
177+
- Sections, cards, panels, containers, borders, backgrounds, shadows, and spacing
178+
- Buttons, links, icons, badges, dropdowns, input fields, and other interactive elements
179+
- Element positions, alignment, relative sizing, padding, margins, and grouping
180+
- Font style, font weight, approximate font size, text alignment, and color usage
181+
- Overlapping, clipped, truncated, hidden, misplaced, or visually broken elements
182+
- Unexpected wrapping, excessive spacing, missing spacing, or layout shifts
183+
- Whether all expected visible UI elements are present
184+
185+
Important text comparison rules:
186+
Do not compare dynamic text values literally. Values such as phone numbers, account numbers, names, balances, prices, dates, times, counts, statuses, identifiers, and user-specific data may be different and must not cause failure.
187+
188+
Treat dynamic text as visual text blocks:
189+
- The exact value may differ.
190+
- The text block should still appear in the expected location.
191+
- It should have similar styling, size, alignment, color, and visual weight.
192+
- It should not break the layout, overlap other elements, be clipped, or cause unexpected wrapping.
193+
194+
Static/template text rules:
195+
Static labels, headings, menu names, fixed links, fixed button labels, fixed section names, and fixed instructional texts should be checked only when they are clearly part of the template.
196+
However, do not fail only because the actual text content differs if the difference appears to be dynamic or user-specific.
197+
198+
Ignore:
199+
- Browser chrome, OS status bars, emulator/device frames, address bars, scroll bars, timestamps, debug overlays, and comparison labels such as "Actual" or "Expected", unless they are part of the application UI.
200+
- Minor anti-aliasing differences, screenshot compression artifacts, tiny pixel-level shifts, and insignificant rendering differences.
201+
- Small differences caused by platform/browser font rendering if the layout and visual hierarchy remain correct.
202+
203+
Fail the comparison when:
204+
- A required UI element is missing or an unexpected major UI element is present.
205+
- Logo, header, menu, navigation, main section, card, button, link, or icon is visually incorrect or misplaced.
206+
- Layout structure differs significantly from the reference.
207+
- Elements overlap, are clipped, truncated, hidden, or visually broken.
208+
- Text blocks are present but their placement, style, size, color, or wrapping materially differs from the reference.
209+
- Spacing, alignment, sizing, or visual hierarchy is noticeably inconsistent with the reference.
210+
- The page looks like a different template, broken responsive layout, or incorrect design version.
211+
212+
Pass the comparison when:
213+
- The actual screenshot preserves the same layout, structure, visual hierarchy, branding, and front-end appearance as the reference.
214+
- Differences are limited to dynamic text values or insignificant rendering variations.
215+
- All expected elements are present and visually usable.
171216
"""
172217
if override_instructions:
173218
instructions = override_instructions

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
1.3.0, 2026-05-25 -- Look and Feel layout comparison assertion strategy improved and made more robust
12
1.2.0, 2026-02-24 -- Image size optimizations, additional_instructions can now be passed to look and feel check keyword
23
1.1.2, 2026-02-09 -- Improved debug logging
34
1.1.1, 2026-02-09 -- Pass/Fail AI response optimized

setup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ def readme():
5353
long_description=readme(),
5454
long_description_content_type='text/markdown',
5555
url='https://github.com/robco/robotframework-aivision.git',
56+
project_urls={
57+
"Homepage": "https://robo-corp.malovec.sk",
58+
"Repository": "https://github.com/robco/robotframework-aivision",
59+
"Documentation": "https://robco.github.io/robotframework-aivision/",
60+
"Issues": "https://github.com/robco/robotframework-aivision/issues",
61+
},
5662
author='Róbert Malovec',
5763
author_email='robert@malovec.sk',
5864
license=license(),

unittests/test_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_verify_screenshot_matches_look_and_feel_template_with_additional_instru
6262
additional_instructions="Ignore status badge."
6363
)
6464
instructions = aivison_library.genai.generate_ai_response.call_args[1]["instructions"]
65-
assert "First image is showing actual application view" in instructions
65+
assert "First image is the actual application screenshot" in instructions
6666
assert instructions.endswith("Ignore status badge.")
6767
aivison_library._assert_result.assert_called_once_with("response")
6868

unittests/test_library.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def test_verify_screenshot_matches_look_and_feel_template(self, library, mock_ge
183183
)
184184

185185
mock_genai.generate_ai_response.assert_called_once()
186-
assert "First image is showing actual application view" in mock_genai.generate_ai_response.call_args[1][
186+
assert "First image is the actual application screenshot" in mock_genai.generate_ai_response.call_args[1][
187187
'instructions']
188188
assert mock_genai.generate_ai_response.call_args[1]['image_paths'] == ["/path/to/screenshot.png",
189189
"/path/to/template.png"]
@@ -213,7 +213,7 @@ def test_verify_screenshot_matches_look_and_feel_template_with_additional_instru
213213

214214
mock_genai.generate_ai_response.assert_called_once()
215215
instructions = mock_genai.generate_ai_response.call_args[1]["instructions"]
216-
assert "First image is showing actual application view" in instructions
216+
assert "First image is the actual application screenshot" in instructions
217217
assert instructions.endswith("Ignore clock in header.")
218218
assert mock_genai.generate_ai_response.call_args[1]["image_paths"] == [
219219
"/path/to/screenshot.png",

0 commit comments

Comments
 (0)