Skip to content

Commit f2338d4

Browse files
committed
take screenshots.
Signed-off-by: Karthik Bekal Pattathana <133984042+karthikbekalp@users.noreply.github.com>
1 parent 515e5db commit f2338d4

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

.github/scripts/xa11y_linux_smoke.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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:

.github/workflows/xa11y_linux_smoke.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ jobs:
6262
python .github/scripts/xa11y_linux_smoke.py
6363
BASH
6464
65-
- name: Upload failure screenshot
66-
if: failure()
65+
- name: Upload screenshots
66+
if: always()
6767
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
6868
with:
6969
name: xa11y-linux-smoke
70-
path: ${{ runner.temp }}/xa11y-linux-smoke.png
70+
path: ${{ runner.temp }}/xa11y-linux-smoke-*.png
7171
if-no-files-found: ignore

0 commit comments

Comments
 (0)