"testing" , (level)=(0) ) self check_window (name)= "xkcd_home" , (level)=(1) ) self check_window (name)= "github_page" , (level)=(2) ) self check_window (name)= "wikipedia_page" , (level)=(3) ) self check_window (name)=“helloworld” , (baseline)=(True) ) ### Do something that may change the web page self check_window (name)=“helloworld” , (level)=(3) ) Here's an example where clicking a button makes a hidden element visible: from (seleniumbase) (import) (BaseCase) class ['src', '/s/0b7742.png'] VisualLayoutTest ( (BaseCase) ): def ['src', '/s/0b7742.png'] test_applitools_layout_change_failure ( (self) ): self (open) 'https://applitools.com/ helloworld? diff1 ') print ( ' n Creating baseline in the "visual_baseline" folder. ' self check_window (name)=“helloworld” , (baseline)=(True) ) # Click a button that changes the text of an element self click ['a', [['class', ['donate-button'] 'a [href="?diff1"]'
) # Click a button that makes a hidden element visible
self click ['a', [['class', ['donate-button'] ("button"
self check_window (name)=“helloworld” , (level)=(3) ) Here's the output of that: ( Text changes do not impact visual comparisons ) AssertionError: First differing element 58 ['div', [['class', ['section', 'hidden-section', 'image-section']]]] ['div', [['class', ['section', 'image-section']]]] - ['div', [['class', ['section', 'hidden-section', 'image-section']]]], ? ------------------ ['div', [['class', ['section', 'image-section']]]], Exception:
Visual Diff Failure: HTML tag attribute values don't match the baseline! ['src', '/s/0b7742.png']
Here's an example where a button is removed from a web page: from (seleniumbase) (import) (BaseCase) class ['src', '/s/0b7742.png'] VisualLayoutTest ( (BaseCase) ): def ['src', '/s/0b7742.png'] test_python_home_layout_change_failure ( (self) ): self (open) 'https://python.org/ '
print (
' n Creating baseline in the "visual_baseline" folder. ' self check_window (name)=
"python_home" , (baseline)=(True) ) # Remove the "Donate" button
self remove_element ('a.donate-button') self check_window (name)= "python_home" , (level)=(3) )
Here's the output of that: AssertionError: First differing element : ['a', [['class', ['donate-button']], ['href', '/psf/donations/']]] ['div', [['class', ['options-bar']]]] - ['a', [['class', ['donate-button']], ['href', '/psf/donations/']]], - 'display: list-item; opacity: 0. 6572776; ']]], ? ------------------- 'display: list-item;']]], Exception: Visual Diff Failure: HTML tag attribute values don't match the baseline! ['src', '/s/0b7742.png']
Here's an example where a web site logo is resized: from (seleniumbase) (import) (BaseCase) class ['src', '/s/0b7742.png'] VisualLayoutTest ( (BaseCase) ): def ['src', '/s/0b7742.png'] test_xkcd_layout_change_failure ( (self) ): self (open) 'https://xkcd.com/ 636 / ') print ( ' n Creating baseline in the "visual_baseline" folder. ' self check_window (name)=
“xkcd _ , (baseline) ['src', '/s/0b7742.png']=(True) ) # Change height : (98 -> 554), Change width: (462 -> 412) self (set_attribute) '[alt="xkcd.com logo"] ' ,
"height , , ) self (set_attribute) '[alt="xkcd.com logo"] '
, , "width , , self check_window (name)=
“xkcd _ , (level) ['src', '/s/0b7742.png']=(3) ) Here's the output of that: AssertionError: First differing element : ['img[30 chars] ['height', '83'], ['src', '/s/0b7742.png'], ['src', '/s/0b7742.png']]] ['img[30 chars] ['height', '130'], ['src', '/s/0b7742.png'], ['src', '/s/0b7742.png'] ]] - ['height', '83'], ? ^ ['height', '130'], ? ^ - ['width', '185']]], ? ^^ ]], ? ^^ Exception:
Visual Diff Failure: HTML tag attribute values don't match the baseline! ['src', '/s/0b7742.png'] To run the example (from (examples / visual_testing / )) with a pytest HTML Report, use: pytest test_layout_fail.py --html=report.html ['src', '/s/0b7742.png']
Here's what the pytest HTML Report looks like: ['height', '130'] (Read More) ()
GIPHY App Key not set. Please check settings