@@ -23,14 +23,16 @@ def _dump_apps() -> None:
2323 print (f"Could not dump accessibility tree: { error } " )
2424
2525
26- def _save_screenshot () -> None :
26+ def _save_screenshot (name : str , * , required : bool = False ) -> None :
2727 try :
2828 artifact_dir = Path (os .environ .get ("XA11Y_SMOKE_ARTIFACT_DIR" , "/tmp" ))
2929 artifact_dir .mkdir (parents = True , exist_ok = True )
30- path = artifact_dir / "xa11y-linux-smoke .png"
30+ path = artifact_dir / f" { name } .png"
3131 xa11y .screenshot ().save_png (str (path ))
3232 print (f"Saved screenshot to { path } " )
3333 except (OSError , xa11y .XA11yError ) as error :
34+ if required :
35+ raise RuntimeError (f"Could not save required screenshot: { error } " ) from error
3436 print (f"Could not save screenshot: { error } " )
3537
3638
@@ -62,6 +64,9 @@ def main() -> None:
6264 if value != MESSAGE :
6365 raise AssertionError (f"Expected text field value { MESSAGE !r} , got { value !r} " )
6466
67+ time .sleep (0.5 )
68+ _save_screenshot ("xa11y-linux-smoke-dialog" , required = True )
69+
6570 ok_button = app .locator ("button[name='OK'], button[name='Ok'], button[name='_OK']" ).first ()
6671 ok_button .wait_visible (timeout = 15 )
6772 ok_button .press ()
@@ -74,7 +79,7 @@ def main() -> None:
7479
7580 print ("PASS: xa11y opened a Linux app, typed text, and closed it." )
7681 except Exception :
77- _save_screenshot ()
82+ _save_screenshot ("xa11y-linux-smoke-failure" )
7883 _dump_apps ()
7984 raise
8085 finally :
0 commit comments