@capagents/forgeqe 3.3.7 → 3.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOW_TO_USE.md +92 -0
- package/dist/a11y-runtime.mjs +3204 -0
- package/dist/docs-site/docs/area-quality/index.html +90 -2
- package/dist/docs-site/docs/overview/index.html +1 -1
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/forgeqe.js +2215 -2094
- package/dist/template.html +69 -70
- package/dist/web/assets/{3d-force-graph-Bsispdm1.js → 3d-force-graph-BPsVSYjw.js} +1 -1
- package/dist/web/assets/Agent-DY6pRvcD.js +10 -0
- package/dist/web/assets/{AgentWork-BugEUl60.js → AgentWork-Brch_Mn3.js} +1 -1
- package/dist/web/assets/ApiTests-BtWKVPw5.js +17 -0
- package/dist/web/assets/{Browse-Dl2Lneca.js → Browse-DbIFxsy8.js} +1 -1
- package/dist/web/assets/Chat-BWiH0XGV.js +3 -0
- package/dist/web/assets/{CommandPalette-B7YPDCOk.js → CommandPalette-DfoEUEL6.js} +1 -1
- package/dist/web/assets/{Compare-D6XsFmmb.js → Compare-DTZ_BW1P.js} +1 -1
- package/dist/web/assets/Cost-DDghPWch.js +1 -0
- package/dist/web/assets/Data-DZlKsTwA.js +6 -0
- package/dist/web/assets/Desktop-DTIZ62Pi.js +1 -0
- package/dist/web/assets/DesktopReview-B8-dSGJH.js +2 -0
- package/dist/web/assets/Evidence-BYw_Q4Ul.js +1 -0
- package/dist/web/assets/Explore-BL_c5WK1.js +2 -0
- package/dist/web/assets/{Features-N3_77mz-.js → Features-DrFNrvbh.js} +1 -1
- package/dist/web/assets/Flags-CHrDwhqG.js +2 -0
- package/dist/web/assets/Flaky-DtcLf8h6.js +1 -0
- package/dist/web/assets/Impact-CMU_ijo2.js +3 -0
- package/dist/web/assets/Jobs-BjybdQb_.js +5 -0
- package/dist/web/assets/KindPage-VK-Vgkzv.js +6 -0
- package/dist/web/assets/{LiveDevice-j7NZXIJZ.js → LiveDevice-BqL1P33F.js} +1 -1
- package/dist/web/assets/Migration-7BI7iXIv.js +8 -0
- package/dist/web/assets/Mobile-AgAhvlVL.js +1 -0
- package/dist/web/assets/Observability-5r36Xf3d.js +1 -0
- package/dist/web/assets/{OwnItems-BdiPfdTw.js → OwnItems-CqCOuvba.js} +4 -4
- package/dist/web/assets/PageAgent-00NQxK49.js +1 -0
- package/dist/web/assets/Product-B75ztJFn.js +6 -0
- package/dist/web/assets/Production-lIUlcjf0.js +1 -0
- package/dist/web/assets/Quality-BlRpB6mx.js +1 -0
- package/dist/web/assets/Readiness-CesaSDtp.js +1 -0
- package/dist/web/assets/Record-CLy9jQ5N.js +1 -0
- package/dist/web/assets/Regression-BjpZrkfK.js +5 -0
- package/dist/web/assets/{RelationGraph-Blfs7PhK.js → RelationGraph-ClPBGuMw.js} +1 -1
- package/dist/web/assets/{Reports-HQkTX4Kr.js → Reports-Du8SNiHM.js} +2 -2
- package/dist/web/assets/Requirements-Dr1iLoMc.js +2 -0
- package/dist/web/assets/Responsive-DcD6MLzG.js +3 -0
- package/dist/web/assets/{RunDiff-75a-smeg.js → RunDiff-cLSFOsfC.js} +1 -1
- package/dist/web/assets/{Settings-BaodIliH.js → Settings-CUT5ggDd.js} +16 -16
- package/dist/web/assets/SiteScan-iUfWBeLV.js +5 -0
- package/dist/web/assets/{Steps-ZPH_rTJh.js → Steps-DJYwIiDu.js} +2 -2
- package/dist/web/assets/{TestData-DUlTo5qt.js → TestData-DqEcL5o4.js} +2 -2
- package/dist/web/assets/TestManagement-mBcfWTVH.js +4 -0
- package/dist/web/assets/{WhatsNew-BrVNacPl.js → WhatsNew-DrPf6l9-.js} +1 -1
- package/dist/web/assets/{agentSettingsSheet-UCqUtdjq.js → agentSettingsSheet-DyaVNewv.js} +1 -1
- package/dist/web/assets/api-Dr3U7W5w.js +1 -0
- package/dist/web/assets/{choice-C4-yW2x9.js → choice-W0qOx_1k.js} +1 -1
- package/dist/web/assets/{coverage-pqIlfEP0.js → coverage-DbHm8BUP.js} +3 -3
- package/dist/web/assets/{dataParts-C0C67bVQ.js → dataParts-Bdf97ZOD.js} +3 -3
- package/dist/web/assets/{desktopAppPath-B89LKvjx.js → desktopAppPath-kQmQOW6a.js} +1 -1
- package/dist/web/assets/{flowTheme-BNKwRxun.js → flowTheme-CVnIjV_m.js} +1 -1
- package/dist/web/assets/frame-CavkQick.js +13 -0
- package/dist/web/assets/index-BaEsXdFc.css +2 -0
- package/dist/web/assets/index-C1kXcI0E.js +57 -0
- package/dist/web/assets/line-icons-Cwj9OmCz.js +1 -0
- package/dist/web/assets/{logos-P2LOMyTK.js → logos-Cf-Wf5ex.js} +1 -1
- package/dist/web/assets/{markdown-CxsWgpYs.js → markdown-Bvv6oj4v.js} +3 -3
- package/dist/web/assets/{nav-DYgvAJu-.js → nav-DVPiPhOy.js} +1 -1
- package/dist/web/assets/pageBack-Blig1Uqs.js +3 -0
- package/dist/web/assets/{palette-BgJTq_Ot.js → palette-DwrGI2Fp.js} +1 -1
- package/dist/web/assets/{paletteCommands-Isq1rLs-.js → paletteCommands-DOF2o-rv.js} +1 -1
- package/dist/web/assets/parts-DgJ2y_ic.js +1 -0
- package/dist/web/assets/{productParts-ZEi0sPIk.js → productParts-B78jij3z.js} +1 -1
- package/dist/web/assets/qualityParts-t5t9kEKG.js +2 -0
- package/dist/web/assets/{recordTest-Bz5ryzpS.js → recordTest-BbXVOuGZ.js} +1 -1
- package/dist/web/assets/{route-oDy8sV6H.js → route-9BkoTWUE.js} +1 -1
- package/dist/web/assets/{sectionList-B651VPon.js → sectionList-DMyhAqst.js} +1 -1
- package/dist/web/assets/{step-mark-CaKf4dAR.js → step-mark-Bu6fNKW8.js} +1 -1
- package/dist/web/assets/stepper-CE4yOLqn.js +1 -0
- package/dist/web/assets/wizardParts-Bxb9UG5k.js +1 -0
- package/dist/web/index.html +11 -11
- package/docs/ForgeQE-Static-Analysis-Report-4008e9ee.html +207 -0
- package/docs/ForgeQE-Static-Analysis-Report-4008e9ee.pdf +0 -0
- package/docs/{ForgeQE-Static-Analysis-Report-5bbf0da7.html → ForgeQE-Static-Analysis-Report-ccbdac00.html} +33 -33
- package/docs/ForgeQE-Static-Analysis-Report-ccbdac00.pdf +0 -0
- package/docs/user-guide.html +89 -1
- package/forgeqe.example.yaml +1 -1
- package/package.json +2 -2
- package/prompts/brain.md +7 -0
- package/py/forgeqe_engine/cli.py +57 -0
- package/py/forgeqe_engine/diagnostics.py +32 -2
- package/py/forgeqe_engine/logins.py +11 -0
- package/py/forgeqe_engine/persona.py +90 -1
- package/py/forgeqe_engine/scan.py +202 -0
- package/py/forgeqe_engine/seo.py +95 -0
- package/py/forgeqe_engine/seo_analytics.mjs +59 -0
- package/py/forgeqe_engine/seo_facts.mjs +63 -0
- package/py/forgeqe_engine/seo_site.mjs +36 -0
- package/py/forgeqe_engine/service.py +3 -2
- package/dist/web/assets/Agent-39FbaH7G.js +0 -10
- package/dist/web/assets/ApiTests-B9rtwCbe.js +0 -17
- package/dist/web/assets/Chat-DocT7FlH.js +0 -3
- package/dist/web/assets/Cost-DvbuXS6u.js +0 -1
- package/dist/web/assets/Data-BmZHJkfj.js +0 -6
- package/dist/web/assets/Desktop-DD3F69ih.js +0 -1
- package/dist/web/assets/DesktopReview-BR0LtVFw.js +0 -2
- package/dist/web/assets/Evidence-OqAiYzrl.js +0 -1
- package/dist/web/assets/Explore-QNyusEFo.js +0 -2
- package/dist/web/assets/Flags-Yv4Ttmmh.js +0 -2
- package/dist/web/assets/Flaky-Bg2f2K1U.js +0 -1
- package/dist/web/assets/Impact-CpxvVnKj.js +0 -3
- package/dist/web/assets/Jobs-_gZTxoaG.js +0 -5
- package/dist/web/assets/KindPage-Amr6R7Ym.js +0 -6
- package/dist/web/assets/Migration-DfPYzTfk.js +0 -8
- package/dist/web/assets/Mobile-fIhhQPsp.js +0 -1
- package/dist/web/assets/Observability-13DkrRp2.js +0 -1
- package/dist/web/assets/PageAgent-CC8Ha6vu.js +0 -1
- package/dist/web/assets/Product-CnXkqwQm.js +0 -6
- package/dist/web/assets/Production-5mTIt4sr.js +0 -1
- package/dist/web/assets/Quality-DbLcbP1X.js +0 -1
- package/dist/web/assets/Readiness-BG1xmC09.js +0 -1
- package/dist/web/assets/Record-sFth-2I1.js +0 -1
- package/dist/web/assets/Regression-Dd4y8I1z.js +0 -5
- package/dist/web/assets/Requirements-DmhUNCIP.js +0 -2
- package/dist/web/assets/Responsive-D18eYdCh.js +0 -3
- package/dist/web/assets/TestManagement-DUMGdHDw.js +0 -4
- package/dist/web/assets/api-D8-lxyQi.js +0 -1
- package/dist/web/assets/frame-C8sL1yo-.js +0 -13
- package/dist/web/assets/index-BFG13fbg.js +0 -55
- package/dist/web/assets/index-DBnWgocz.css +0 -2
- package/dist/web/assets/line-icons-CwCZidXs.js +0 -1
- package/dist/web/assets/pageBack-BefA2rh7.js +0 -3
- package/dist/web/assets/parts-BNpm4gXC.js +0 -1
- package/dist/web/assets/qualityParts-DtsD70Qh.js +0 -1
- package/dist/web/assets/stepper-CONWT_tv.js +0 -1
- package/dist/web/assets/wizardParts-CulZqqjz.js +0 -1
package/docs/user-guide.html
CHANGED
|
@@ -410,7 +410,7 @@ forgeqe docs --copy ./docs # copy the guide, the architecture page, the refere
|
|
|
410
410
|
<div class="area"><a class="area-name" href="#area-automated-tests"><span class="mono">Automated tests</span></a><ul class="tiles"><li><a class="tile" href="#cap-write-tests"><b>Turn a passed run into an automated test</b><span>Write a Playwright test for that run in ../app</span></a></li><li><a class="tile" href="#cap-heal-tests"><b>Heal failing tests</b><span>Heal the failing tests in ../app</span></a></li><li><a class="tile" href="#cap-migrate-tests"><b>Migrate a test suite</b><span>Migrate the Selenium tests in tests/ to Playwright TypeScript</span></a></li><li><a class="tile" href="#cap-tosca-convert"><b>Convert Tosca test cases</b><span>Convert the Tosca export tosca/checkout.tsu to Playwright TypeScript</span></a></li><li><a class="tile" href="#cap-find-run-tests"><b>Find and run existing tests</b><span>Run the checkout tests</span></a></li><li><a class="tile" href="#cap-regression-packs"><b>Regression packs for a release</b><span>Build a regression pack for sprint 12 and run it on TestMu</span></a></li><li><a class="tile" href="#cap-flaky-tests"><b>Flaky test detection and quarantine</b><span>Which tests are flaky?</span></a></li><li><a class="tile" href="#cap-run-diff"><b>Compare two runs step by step</b><span>It passed yesterday and fails today: why?</span></a></li><li><a class="tile" href="#cap-test-debt"><b>Test debt and coverage gaps</b><span>What has no test?</span></a></li><li><a class="tile" href="#cap-test-management"><b>Test management</b><span>Show the test inventory</span></a></li></ul></div>
|
|
411
411
|
<div class="area"><a class="area-name" href="#area-pull-requests"><span class="mono">Pull requests</span></a><ul class="tiles"><li><a class="tile" href="#cap-pr-review"><b>Review pull requests</b><span>Review PR 42 and focus on error handling</span></a></li><li><a class="tile" href="#cap-pr-impact"><b>Pull request impact and test selection</b><span>What does PR 42 impact?</span></a></li></ul></div>
|
|
412
412
|
<div class="area"><a class="area-name" href="#area-api"><span class="mono">API</span></a><ul class="tiles"><li><a class="tile" href="#cap-api-testing"><b>API and contract testing</b><span>Turn the last run's API calls into tests</span></a></li><li><a class="tile" href="#cap-api-calls"><b>An API's calls and collections</b><span>Import our Postman collection and send its calls</span></a></li><li><a class="tile" href="#cap-api-load-security"><b>API load and security checks</b><span>Load test the orders API with 20 users for a minute</span></a></li></ul></div>
|
|
413
|
-
<div class="area"><a class="area-name" href="#area-quality"><span class="mono">Quality</span></a><ul class="tiles"><li><a class="tile" href="#cap-load-testing"><b>Load testing with JMeter</b><span>Write a load test for checkout with 200 users over 10 minutes</span></a></li><li><a class="tile" href="#cap-accessibility-performance"><b>Accessibility and page performance</b><span>Is the checkout page accessible?</span></a></li><li><a class="tile" href="#cap-accessibility-personas"><b>Accessibility testing with personas</b><span>Act as a blind person and use the website to find accessibility issues</span></a></li><li><a class="tile" href="#cap-visual-comparison"><b>Visual comparison with baselines</b><span>What changed visually since the last run?</span></a></li><li><a class="tile" href="#cap-defect-intelligence"><b>Defect intelligence: trends and prediction</b><span>Which defects keep coming back?</span></a></li><li><a class="tile" href="#cap-security-smoke"><b>Passive security smoke checks</b><span>Any security problems in the last checkout run?</span></a></li><li><a class="tile" href="#cap-localization-checks"><b>Localization checks</b><span>Is the German checkout fully translated?</span></a></li><li><a class="tile" href="#cap-responsive-check"><b>Responsive check</b><span>Does the checkout page work on phones?</span></a></li></ul></div>
|
|
413
|
+
<div class="area"><a class="area-name" href="#area-quality"><span class="mono">Quality</span></a><ul class="tiles"><li><a class="tile" href="#cap-load-testing"><b>Load testing with JMeter</b><span>Write a load test for checkout with 200 users over 10 minutes</span></a></li><li><a class="tile" href="#cap-accessibility-performance"><b>Accessibility and page performance</b><span>Is the checkout page accessible?</span></a></li><li><a class="tile" href="#cap-site-scan"><b>Site scan: SEO, analytics, WCAG</b><span>Scan these five pages for accessibility and SEO</span></a></li><li><a class="tile" href="#cap-accessibility-personas"><b>Accessibility testing with personas</b><span>Act as a blind person and use the website to find accessibility issues</span></a></li><li><a class="tile" href="#cap-visual-comparison"><b>Visual comparison with baselines</b><span>What changed visually since the last run?</span></a></li><li><a class="tile" href="#cap-defect-intelligence"><b>Defect intelligence: trends and prediction</b><span>Which defects keep coming back?</span></a></li><li><a class="tile" href="#cap-security-smoke"><b>Passive security smoke checks</b><span>Any security problems in the last checkout run?</span></a></li><li><a class="tile" href="#cap-localization-checks"><b>Localization checks</b><span>Is the German checkout fully translated?</span></a></li><li><a class="tile" href="#cap-responsive-check"><b>Responsive check</b><span>Does the checkout page work on phones?</span></a></li></ul></div>
|
|
414
414
|
<div class="area"><a class="area-name" href="#area-release"><span class="mono">Release</span></a><ul class="tiles"><li><a class="tile" href="#cap-release-readiness"><b>Requirement coverage and release readiness</b><span>Are we ready to release?</span></a></li><li><a class="tile" href="#cap-release-verdict"><b>One release verdict from everything measured</b><span>Can we ship release-2.3?</span></a></li><li><a class="tile" href="#cap-feature-flags"><b>Regression across feature-flag combinations</b><span>Run the release pack across the new-checkout feature flag on and off</span></a></li><li><a class="tile" href="#cap-reports"><b>Reports you can share</b><span>Create a release report for all projects</span></a></li></ul></div>
|
|
415
415
|
<div class="area"><a class="area-name" href="#area-systems"><span class="mono">Systems</span></a><ul class="tiles"><li><a class="tile" href="#cap-systems"><b>Work with Azure DevOps, Jira, GitHub, and Confluence</b><span>Show the open bugs in this sprint</span></a></li><li><a class="tile" href="#cap-system-data"><b>Read any data in Azure DevOps, Jira, Xray, and Confluence, and open Azure DevOps pull requests</b><span>Are there open pull requests in any repository of QI-Claims?</span></a></li></ul></div>
|
|
416
416
|
<h3 class="band-title">Not supported</h3>
|
|
@@ -10828,6 +10828,87 @@ forgeqe quality trends shop.test # per page over time; exits 1 when a page go
|
|
|
10828
10828
|
</section>
|
|
10829
10829
|
</div>
|
|
10830
10830
|
</article>
|
|
10831
|
+
<article class="spec feat" id="cap-site-scan">
|
|
10832
|
+
<div class="hd"><span class="mono">Quality</span><h3>Site scan: SEO, analytics, WCAG</h3></div>
|
|
10833
|
+
<p class="ds">Checks up to 25 pages, with no model, for accessibility and WCAG coverage, SEO, analytics tags and Core Web Vitals; HTML and PDF report, and a dashboard over time.</p>
|
|
10834
|
+
<div class="facts">
|
|
10835
|
+
<div class="fact"><span class="mono">Ask it</span><ul class="asks"><li>Scan these five pages for accessibility and SEO</li><li>Which analytics tags does our site load, and do they fire before consent?</li><li>Show the quality dashboard of our sites for the last 30 days</li></ul></div>
|
|
10836
|
+
<div class="fact"><span class="mono">What it needs</span><p class="muted">Nothing beyond ForgeQE itself.</p></div>
|
|
10837
|
+
<div class="fact"><span class="mono">Limits</span><ul class="plainlist"><li>Opens each page as it first loads: nothing is clicked, typed or submitted, so INP and content behind interactions are not measured (that is browser_run or accessibility_test).</li><li>Analytics are read from what the page loads with no consent given; a tag that waits for consent shows as loaded with no hit.</li></ul></div>
|
|
10838
|
+
<div class="fact"><span class="mono">Tools</span><p class="tools"><code>site_scan</code> <code>quality_dashboard</code> <code>wcag_coverage</code> <code>a11y_suite</code></p></div>
|
|
10839
|
+
</div>
|
|
10840
|
+
<div class="detail"><span class="mono">In detail</span>
|
|
10841
|
+
<section class="doc" id="doc-how_to_use-site-scan-accessibility-seo-and-analytics">
|
|
10842
|
+
<h4>Site scan: accessibility, SEO and analytics</h4>
|
|
10843
|
+
<div class="prose"><p>A site scan opens up to 25 pages in ForgeQE's browser, one after another, with no model and nothing clicked, typed or
|
|
10844
|
+
submitted, and checks each page:</p>
|
|
10845
|
+
<ul>
|
|
10846
|
+
<li><strong>Accessibility</strong>: the rule engine and standard of <code>quality.accessibility</code> (or the ones you pick), the rules that
|
|
10847
|
+
failed, and the rules that <strong>need a person's review</strong>.</li>
|
|
10848
|
+
<li><strong>WCAG coverage</strong>: every success criterion of the standard, with its result (see above).</li>
|
|
10849
|
+
<li><strong>SEO</strong>: the status code, HTTPS, whether search engines may index it (robots meta tag, robots.txt), the title and
|
|
10850
|
+
meta description (length, duplicates), one <code><h1></code>, heading order, the language, the canonical link, language
|
|
10851
|
+
versions (hreflang), the mobile viewport, mixed content, page weight, image alt attributes, link text, the social
|
|
10852
|
+
preview (Open Graph), structured data (JSON-LD) and the favicon; for each site, robots.txt and the sitemap. Each page
|
|
10853
|
+
gets a score: the weighted share of its checks that passed, a warning counting half.</li>
|
|
10854
|
+
<li><strong>Analytics</strong>: which tags each page loads (Google Analytics 4, Universal Analytics, Tag Manager, Google Ads, Adobe
|
|
10855
|
+
Analytics, Meta Pixel, Microsoft Clarity, Hotjar, Segment, Mixpanel, Amplitude, Heap, Matomo, Plausible, PostHog,
|
|
10856
|
+
LinkedIn Insight, TikTok Pixel, Microsoft Advertising UET, Piano Analytics), their ids, and what is wrong: a tag on
|
|
10857
|
+
some pages of a site and not others, a tag loaded twice, a tag loaded that sent nothing, Universal Analytics (it no
|
|
10858
|
+
longer collects data), and <strong>hits sent before anyone answered the consent banner</strong>. Google's consent mode is read
|
|
10859
|
+
from the hits: a cookieless ping while consent is denied is not counted as tracking.</li>
|
|
10860
|
+
<li><strong>Performance</strong>: each page's Core Web Vitals of its first load against Google's thresholds. INP needs an
|
|
10861
|
+
interaction, which a scan does not make.</li>
|
|
10862
|
+
</ul>
|
|
10863
|
+
<p>Each page is opened fresh, with no consent given. Signed-in pages use the saved sessions of your logins (<code>forgeqe login</code>); a scan never types a password.</p>
|
|
10864
|
+
<p><strong>Web app.</strong> Open <strong>Site scan</strong> (Quality), paste the addresses or pick a CSV (every cell that is an http(s) address
|
|
10865
|
+
is used), pick the standard and engine, and press <strong>Scan</strong>. Each scan's result has tabs for each part, and buttons
|
|
10866
|
+
for the HTML report, the PDF and the coverage CSV. The <strong>Dashboard</strong> shows each site over 7, 30 or 90 days or all
|
|
10867
|
+
time: violations, SEO score and LCP per run, the analytics tools, and the WCAG rules newly failing or fixed. <strong>WCAG
|
|
10868
|
+
coverage</strong> shows what ForgeQE can check for a standard and engine, with CSV, HTML and PDF downloads.</p>
|
|
10869
|
+
<p><strong>Terminal</strong></p>
|
|
10870
|
+
<pre><code class="language-bash">forgeqe scan https://shop.test/ https://shop.test/basket --standard wcag22aa --pdf
|
|
10871
|
+
forgeqe scan --csv pages.csv # every http(s) address in the file (inside the project)
|
|
10872
|
+
forgeqe a11y coverage --standard wcag22aa --engine ibm # what can be checked, criterion by criterion
|
|
10873
|
+
forgeqe a11y coverage --scan 20261201-112739 # a scan's results
|
|
10874
|
+
forgeqe quality dashboard --range 90d
|
|
10875
|
+
</code></pre>
|
|
10876
|
+
<p>A scan is a run folder of the reports folder: <code>scan-report.html</code> (no script, nothing loaded from outside), and
|
|
10877
|
+
<code>scan-report.pdf</code> printed from it by ForgeQE's browser with JavaScript off. <code>accessibility.json</code>, <code>performance.json</code> and
|
|
10878
|
+
<code>seo.json</code> hold the data, so <strong>Quality</strong> lists the scan too and its results join the history the dashboard reads. It
|
|
10879
|
+
exits 1 when a page could not be opened or a WCAG rule failed, so a pipeline can gate on it.</p>
|
|
10880
|
+
<p><strong>Regression suites: run it all again, with no model.</strong> A suite keeps what to check again in the repository,
|
|
10881
|
+
<code>.forgeqe/accessibility-suites/<name>.yaml</code>: the pages of a scan, and persona sessions with each persona's settings
|
|
10882
|
+
frozen in (device, zoom, text size, colour vision, motion, contrast, keyboard or screen reader) and the journey each
|
|
10883
|
+
persona's run recorded: every key a keyboard user pressed and what it focused, every swipe and double tap of a screen
|
|
10884
|
+
reader user and what it reached, every click and field of a persona who uses the mouse.</p>
|
|
10885
|
+
<pre><code class="language-bash">forgeqe a11y suite create checkout --scan 20261201-113906 --session 20261201-122718-find-the-contact-page
|
|
10886
|
+
forgeqe a11y suite run checkout # no model: replays the journeys, scans the pages
|
|
10887
|
+
forgeqe a11y suite baseline checkout --run 20261201-123219 # a person approves it (types the name)
|
|
10888
|
+
forgeqe a11y suite run checkout # later: exits 1 when anything got worse than the baseline
|
|
10889
|
+
forgeqe a11y suite run checkout --heal # the persona agent goes through again where a journey broke (a model's run)
|
|
10890
|
+
forgeqe a11y suite tests checkout # JavaScript Playwright tests in a11y-tests/checkout
|
|
10891
|
+
</code></pre>
|
|
10892
|
+
<p>A run fails only on what got worse than the baseline: a WCAG criterion that now fails, a rule newly failing on a page,
|
|
10893
|
+
a page that no longer opens, an SEO score down by 5 or more, an analytics tag gone, a persona who no longer gets
|
|
10894
|
+
through (a key that now focuses something else, an element a screen reader user activated that is gone, a link that no
|
|
10895
|
+
longer leads where it did). A replay judges no barrier anew; <code>--heal</code> has the persona agent go through again where the
|
|
10896
|
+
page changed, and its new journey replaces the old one only when a person approves that run as the baseline.</p>
|
|
10897
|
+
<p><strong>The JavaScript tests</strong> need no model and no ForgeQE: <code>cd a11y-tests/checkout && npm install && npx playwright install chrome && npx playwright test</code>. They hold no recorded value as code: the pages, personas and journeys are data in
|
|
10898
|
+
<code>suite.json</code>, judged against <code>baseline.json</code> by the same runtime ForgeQE's own runs use (<code>forgeqe-a11y.mjs</code>), with
|
|
10899
|
+
axe-core 4.14.0 and ForgeQE's SEO and analytics scripts beside them. Values a journey types come from environment
|
|
10900
|
+
variables (the README names them). They write <code>results/snapshot.json</code>, <code>junit.xml</code> and an HTML report; <code>forgeqe a11y suite baseline checkout --from a11y-tests/checkout/results/snapshot.json</code> makes a CI run the baseline. Write them again
|
|
10901
|
+
after the suite or its baseline changes.</p>
|
|
10902
|
+
<p>On the page: <strong>Accessibility › Suites</strong> makes a suite from a scan and sessions, runs it, shows each run against the
|
|
10903
|
+
baseline, approves a run as the baseline (type the suite's name) and writes the tests.</p>
|
|
10904
|
+
<p><strong>Rules never prove conformance.</strong> ForgeQE counts a criterion as covered by rules only when a rule the engine actually
|
|
10905
|
+
runs for the standard checks it: axe-core's experimental and deprecated rules are left out, because axe-core does not
|
|
10906
|
+
run them under a standard's tags. With axe-core 4.14, 21 of the 55 WCAG 2.2 AA criteria have rules; with IBM Equal
|
|
10907
|
+
Access 4.0, 33. The personas exercise most of the rest; the criteria neither reaches still need a person.</p>
|
|
10908
|
+
</div>
|
|
10909
|
+
</section>
|
|
10910
|
+
</div>
|
|
10911
|
+
</article>
|
|
10831
10912
|
<article class="spec feat" id="cap-accessibility-personas">
|
|
10832
10913
|
<div class="hd"><span class="mono">Quality</span><h3>Accessibility testing with personas</h3></div>
|
|
10833
10914
|
<p class="ds">A browser agent does a goal as a person with a disability would (a blind screen reader user, keyboard only, low vision, colour blind, cognitive, or the project's own personas) and records each barrier with its WCAG criterion and severity. Not functional testing.</p>
|
|
@@ -10899,6 +10980,13 @@ watch_for:
|
|
|
10899
10980
|
</code></pre>
|
|
10900
10981
|
<p>A persona file can come from the repository, so ForgeQE reads it strictly: only these keys, each setting from its list, no YAML aliases. Its text describes the person to the browser model; what the browser does comes only from the settings.</p>
|
|
10901
10982
|
<p>A simulated persona is not a real user, and automated checks find only part of the problems. Treat the result as a first pass, and confirm important barriers with people who use assistive technology.</p>
|
|
10983
|
+
<p><strong>WCAG coverage of a session.</strong> Each session also writes <code>coverage.html</code> and <code>coverage.csv</code> beside its report: every
|
|
10984
|
+
success criterion of the session's standard with one result, the worst that holds. <strong>Failed</strong> means a rule failed or a
|
|
10985
|
+
persona met a barrier of it. <strong>Needs review</strong> means a rule ran and could not decide (axe-core's "incomplete", IBM's
|
|
10986
|
+
potential violations), so a person has to look. <strong>Exercised by a persona</strong> means a persona who uses the page that way
|
|
10987
|
+
(keyboard only for focus order, 200% zoom for reflow) reached the goal with no barrier of it. <strong>Rules passed</strong> means
|
|
10988
|
+
its rules ran and passed. <strong>Not tested</strong> means nothing checked it. On the page, the session's <strong>Coverage</strong> tab shows
|
|
10989
|
+
the same; in a terminal, <code>forgeqe a11y coverage --session <folder name></code>.</p>
|
|
10902
10990
|
</div>
|
|
10903
10991
|
</section>
|
|
10904
10992
|
</div>
|
package/forgeqe.example.yaml
CHANGED
|
@@ -616,7 +616,7 @@ suite:
|
|
|
616
616
|
# are reported and tracked over time; a run fails on them only when a budget below is exceeded.
|
|
617
617
|
# quality:
|
|
618
618
|
# accessibility:
|
|
619
|
-
# standard: wcag21aa # wcag2a, wcag21aa, wcag22aa,
|
|
619
|
+
# standard: wcag21aa # wcag2a, wcag2aa, wcag2aaa, wcag21a, wcag21aa, wcag21aaa, wcag22a, wcag22aa, wcag22aaa, section508, en301549, best-practice
|
|
620
620
|
# engine: axe # axe (axe-core), ibm (IBM Equal Access: up to AA, no AAA rules), basic (ForgeQE's own)
|
|
621
621
|
# ask_before_run: true # false: a persona session runs its browser runs without asking first
|
|
622
622
|
# visual: # each page compared with its approved screenshot (.forgeqe/visual-baselines)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capagents/forgeqe",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.9",
|
|
4
4
|
"description": "ForgeQE: a browser agent CLI that runs goals and test cases in local Chrome or Chromium, or BrowserStack and TestMu AI/LambdaTest when configured, and turns passing runs into tests in your repo",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"test": "bun test",
|
|
54
54
|
"test:release": "bun scripts/release-tests.ts",
|
|
55
55
|
"typecheck": "tsc --noEmit",
|
|
56
|
-
"build:report": "cd report-ui && npm install --no-audit --no-fund && npm run build && node -e \"require('fs').copyFileSync('dist/index.html', '../src/report/template.html')\"",
|
|
56
|
+
"build:report": "bun scripts/sync-report-ui.ts && cd report-ui && npm install --no-audit --no-fund && npm run build && node -e \"require('fs').copyFileSync('dist/index.html', '../src/report/template.html')\"",
|
|
57
57
|
"build:web": "cd web && npm install --no-audit --no-fund && npm run build",
|
|
58
58
|
"audit:layers": "bun web/scripts/audit-layers.ts",
|
|
59
59
|
"build:docs": "bun scripts/build-docs-site.ts",
|
package/prompts/brain.md
CHANGED
|
@@ -409,6 +409,13 @@ For testing with flags on and off, or across flag combinations:
|
|
|
409
409
|
- A change that is not intended is a visual defect. A run fails on it only with quality.budgets.visual.
|
|
410
410
|
- To set budgets, edit quality.budgets in forgeqe.yaml: accessibility (violations for each impact, rules to pass or ignore) and performance (web-vitals, or limits for each metric and page).
|
|
411
411
|
|
|
412
|
+
### Site scans, SEO and analytics
|
|
413
|
+
- To check a list of pages for accessibility, SEO or analytics tags, use site_scan. It opens each page and clicks nothing. For a journey through the site, use accessibility_test or browser_run.
|
|
414
|
+
- For "what does our accessibility testing cover" or "which WCAG criteria failed", use wcag_coverage. Say that rules that pass do not prove a criterion is met.
|
|
415
|
+
- For "how did the site do this month" or a trend of SEO, use quality_dashboard.
|
|
416
|
+
- To check pages or persona sessions again later, or for a script that runs with no model, use a11y_suite. A person approves the baseline: you MUST NOT offer to do it.
|
|
417
|
+
- Say an analytics finding of "hits before consent" as a possible privacy issue to confirm, not as a legal finding.
|
|
418
|
+
|
|
412
419
|
### Load testing with JMeter
|
|
413
420
|
For "load test", "stress test", "how many users can it take", "soak", "spike", or a JMeter plan (.jmx):
|
|
414
421
|
- Plans are JMeter .jmx files in perf.folder (default perf/) of the test repository. perf_plans lists them, with the load each declares and whether ForgeQE may run it.
|
package/py/forgeqe_engine/cli.py
CHANGED
|
@@ -153,6 +153,59 @@ def _run(out: TextIO) -> int:
|
|
|
153
153
|
return asyncio.run(main())
|
|
154
154
|
|
|
155
155
|
|
|
156
|
+
def _scan(out: TextIO) -> int:
|
|
157
|
+
"""stdin line 1: the scan request (scan.py); a later "stop" or EOF ends it, keeping what it checked."""
|
|
158
|
+
from .scan import run_scan
|
|
159
|
+
|
|
160
|
+
line = sys.stdin.readline()
|
|
161
|
+
payload = json.loads(line) if line.strip() else {}
|
|
162
|
+
lock = threading.Lock()
|
|
163
|
+
|
|
164
|
+
def emit(event: Dict[str, Any]) -> None:
|
|
165
|
+
with lock:
|
|
166
|
+
out.write(json.dumps(event, ensure_ascii=False, default=str) + "\n")
|
|
167
|
+
out.flush()
|
|
168
|
+
|
|
169
|
+
async def main() -> int:
|
|
170
|
+
loop = asyncio.get_running_loop()
|
|
171
|
+
cancel = asyncio.Event()
|
|
172
|
+
|
|
173
|
+
def watch_stdin() -> None:
|
|
174
|
+
for cmd in sys.stdin:
|
|
175
|
+
if cmd.strip().lower() == "stop":
|
|
176
|
+
break
|
|
177
|
+
loop.call_soon_threadsafe(cancel.set)
|
|
178
|
+
|
|
179
|
+
threading.Thread(target=watch_stdin, daemon=True).start()
|
|
180
|
+
try:
|
|
181
|
+
result = await run_scan(payload if isinstance(payload, dict) else {}, emit, cancel)
|
|
182
|
+
except Exception as e:
|
|
183
|
+
result = {"success": False, "error": str(e)[:600]}
|
|
184
|
+
emit({"type": "done", "result": result})
|
|
185
|
+
return 0 if result.get("success") else 1
|
|
186
|
+
|
|
187
|
+
return asyncio.run(main())
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def _pdf(out: TextIO) -> int:
|
|
191
|
+
"""stdin line 1: {html, pdf, browser}: a report ForgeQE wrote, printed to PDF (scan.print_pdf)."""
|
|
192
|
+
from .scan import print_pdf
|
|
193
|
+
|
|
194
|
+
line = sys.stdin.readline()
|
|
195
|
+
payload = json.loads(line) if line.strip() else {}
|
|
196
|
+
|
|
197
|
+
def emit(event: Dict[str, Any]) -> None:
|
|
198
|
+
out.write(json.dumps(event, ensure_ascii=False, default=str) + "\n")
|
|
199
|
+
out.flush()
|
|
200
|
+
|
|
201
|
+
try:
|
|
202
|
+
result = asyncio.run(print_pdf(payload if isinstance(payload, dict) else {}, emit))
|
|
203
|
+
except Exception as e:
|
|
204
|
+
result = {"success": False, "error": str(e)[:600]}
|
|
205
|
+
emit({"type": "done", "result": result})
|
|
206
|
+
return 0 if result.get("success") else 1
|
|
207
|
+
|
|
208
|
+
|
|
156
209
|
def _login(out: TextIO) -> int:
|
|
157
210
|
"""
|
|
158
211
|
stdin line 1: {url, logins: [login]}; then each "save" tries to save the session (the browser stays open while
|
|
@@ -351,6 +404,10 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
351
404
|
return _run(out)
|
|
352
405
|
if cmd == "login":
|
|
353
406
|
return _login(out)
|
|
407
|
+
if cmd == "scan":
|
|
408
|
+
return _scan(out)
|
|
409
|
+
if cmd == "pdf":
|
|
410
|
+
return _pdf(out)
|
|
354
411
|
if cmd == "record":
|
|
355
412
|
return _record(out)
|
|
356
413
|
if cmd == "code":
|
|
@@ -17,6 +17,7 @@ from urllib.parse import urlsplit
|
|
|
17
17
|
|
|
18
18
|
from .brand import clean_capture
|
|
19
19
|
from .network import NetworkCapture, hook
|
|
20
|
+
from .seo import SeoCollector
|
|
20
21
|
|
|
21
22
|
logger = logging.getLogger(__name__)
|
|
22
23
|
|
|
@@ -345,8 +346,10 @@ def box_for(browser_state: Any, index: Any) -> Optional[Dict[str, float]]:
|
|
|
345
346
|
|
|
346
347
|
|
|
347
348
|
class Diagnostics:
|
|
348
|
-
def __init__(self, *, accessibility: bool = True, network: bool = True, axe: Optional[Dict[str, Any]] = None, vitals: bool = True, visual: Optional[Dict[str, Any]] = None, keep_headers: Optional[List[str]] = None, ibm: Optional[Dict[str, Any]] = None) -> None:
|
|
349
|
+
def __init__(self, *, accessibility: bool = True, network: bool = True, axe: Optional[Dict[str, Any]] = None, vitals: bool = True, visual: Optional[Dict[str, Any]] = None, keep_headers: Optional[List[str]] = None, ibm: Optional[Dict[str, Any]] = None, seo: bool = False) -> None:
|
|
349
350
|
self.accessibility = accessibility
|
|
351
|
+
# A scan's SEO facts and analytics tags (seo.py); off for runs, where the agent's clicks change what loaded.
|
|
352
|
+
self.seo: Optional[SeoCollector] = SeoCollector() if seo else None
|
|
350
353
|
# axe-core: {"script": path to axe.min.js, "tags": ["wcag2a", "wcag2aa"]}; without it, the built-in checks.
|
|
351
354
|
self.axe_tags: List[str] = [str(t) for t in ((axe or {}).get("tags") or ["wcag2a", "wcag2aa"])]
|
|
352
355
|
self._axe_source: Optional[str] = None
|
|
@@ -375,7 +378,7 @@ class Diagnostics:
|
|
|
375
378
|
# {"mask": [selectors], "pages": {"/path": [selectors]}, "full_page": bool}; None: no visual captures.
|
|
376
379
|
self.visual: Optional[Dict[str, Any]] = visual
|
|
377
380
|
self.shots: Dict[str, Dict[str, Any]] = {}
|
|
378
|
-
self.timeout = CHECK_TIMEOUT * (3 if self._axe_source or self._ibm_source else 1)
|
|
381
|
+
self.timeout = CHECK_TIMEOUT * (3 if self._axe_source or self._ibm_source else 1) + (20.0 if seo else 0.0)
|
|
379
382
|
self.network: Optional[NetworkCapture] = NetworkCapture(keep_headers) if network else None
|
|
380
383
|
self._net_handlers: Dict[str, Any] = {}
|
|
381
384
|
self.events: List[Dict[str, Any]] = []
|
|
@@ -524,12 +527,31 @@ class Diagnostics:
|
|
|
524
527
|
"url": url, "ms": int(r["ms"])})
|
|
525
528
|
if self.vitals:
|
|
526
529
|
await self._read_vitals(session)
|
|
530
|
+
# Before the page is checked or localized (which changes its text for a moment), so the facts are the page's own.
|
|
531
|
+
if self.seo is not None:
|
|
532
|
+
await self._collect_seo(browser, session)
|
|
527
533
|
if self.accessibility:
|
|
528
534
|
await self._check_page(browser, session)
|
|
529
535
|
await self._localize(session)
|
|
530
536
|
if self.visual is not None:
|
|
531
537
|
await self._capture(session)
|
|
532
538
|
|
|
539
|
+
async def _collect_seo(self, browser: Any, session: Any) -> None:
|
|
540
|
+
try:
|
|
541
|
+
url = str(await browser.get_current_page_url() or "")
|
|
542
|
+
except Exception:
|
|
543
|
+
return
|
|
544
|
+
if not url.startswith("http"):
|
|
545
|
+
return
|
|
546
|
+
|
|
547
|
+
async def evaluate(expression: str, await_promise: bool) -> Any:
|
|
548
|
+
r = await session.cdp_client.send.Runtime.evaluate(
|
|
549
|
+
params={"expression": expression, "returnByValue": True, "awaitPromise": await_promise}, session_id=session.session_id
|
|
550
|
+
)
|
|
551
|
+
return ((r or {}).get("result") or {}).get("value")
|
|
552
|
+
|
|
553
|
+
await self.seo.collect(evaluate, _page_key(url))
|
|
554
|
+
|
|
533
555
|
async def _localize(self, session: Any) -> None:
|
|
534
556
|
"""A page not seen before: its language checks as it is, then with pseudo-localized text and right to left."""
|
|
535
557
|
try:
|
|
@@ -819,6 +841,14 @@ class Diagnostics:
|
|
|
819
841
|
file.write_text(json.dumps(list(self.pages.values()), indent=2, ensure_ascii=False), encoding="utf-8")
|
|
820
842
|
return str(file.resolve())
|
|
821
843
|
|
|
844
|
+
def write_seo(self, out_dir: Path) -> Optional[str]:
|
|
845
|
+
data = self.seo.result() if self.seo is not None else None
|
|
846
|
+
if not data:
|
|
847
|
+
return None
|
|
848
|
+
file = out_dir / "seo.json"
|
|
849
|
+
file.write_text(json.dumps(data, indent=2, ensure_ascii=False), encoding="utf-8")
|
|
850
|
+
return str(file.resolve())
|
|
851
|
+
|
|
822
852
|
def write_perf(self, out_dir: Path) -> Optional[str]:
|
|
823
853
|
if not self.perf:
|
|
824
854
|
return None
|
|
@@ -142,6 +142,17 @@ def use_logins(logins: List[Login]) -> Tuple[Dict[str, Dict[str, str]], List[str
|
|
|
142
142
|
_NAME = re.compile(r"^[A-Za-z_][A-Za-z0-9_]{0,63}$")
|
|
143
143
|
|
|
144
144
|
|
|
145
|
+
def login_values_by_env(data: Dict[str, Dict[str, str]]) -> Dict[str, str]:
|
|
146
|
+
"""Each saved value of use_logins' data by its environment variable's name (a one-time code's secret left out)."""
|
|
147
|
+
out: Dict[str, str] = {}
|
|
148
|
+
for per in data.values():
|
|
149
|
+
for key, value in per.items():
|
|
150
|
+
kind_env = _PLACEHOLDERS.get(key)
|
|
151
|
+
if kind_env and kind_env[0] != "totp" and value:
|
|
152
|
+
out[kind_env[1]] = value
|
|
153
|
+
return out
|
|
154
|
+
|
|
155
|
+
|
|
145
156
|
def use_env_secrets(data: Dict[str, Dict[str, str]], items: Any) -> List[str]:
|
|
146
157
|
"""
|
|
147
158
|
Add the environment's secret variables (env.yaml ``TestPassword: password``) to ``data``, the library's sensitive_data,
|
|
@@ -461,9 +461,89 @@ def save_findings(out_dir: str, persona: Dict[str, Any], findings: List[Dict[str
|
|
|
461
461
|
logger.warning("%s not written: %s", FINDINGS_FILE, ex)
|
|
462
462
|
|
|
463
463
|
|
|
464
|
-
|
|
464
|
+
JOURNEY_FILE = "persona-journey.json"
|
|
465
|
+
MAX_JOURNEY = 400
|
|
466
|
+
|
|
467
|
+
_IDENTITY_FN = """function () {
|
|
468
|
+
const a = (n) => (this.getAttribute(n) || '').slice(0, 200);
|
|
469
|
+
return { tag: this.tagName.toLowerCase(), id: (this.id || '').slice(0, 200), testid: a('data-testid') || a('data-test') || a('data-cy'), href: a('href') };
|
|
470
|
+
}"""
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
async def identity(browser_session: BrowserSession, *, backend: Optional[int] = None, active: bool = False) -> Dict[str, str]:
|
|
474
|
+
"""
|
|
475
|
+
An element as a replay finds it again: its accessible role and name (as the screen reader has them), and its tag,
|
|
476
|
+
id, test id and link. Of a DOM node by its backend id, or of what has focus. Every value plain text, clipped.
|
|
477
|
+
"""
|
|
478
|
+
out: Dict[str, str] = {}
|
|
479
|
+
try:
|
|
480
|
+
cdp = await _cdp(browser_session)
|
|
481
|
+
send, sid = cdp.cdp_client.send, cdp.session_id
|
|
482
|
+
if active:
|
|
483
|
+
ref = (await send.Runtime.evaluate(params={"expression": "document.activeElement", "returnByValue": False}, session_id=sid)).get("result") or {}
|
|
484
|
+
object_id = ref.get("objectId")
|
|
485
|
+
else:
|
|
486
|
+
await send.DOM.getDocument(params={"depth": 0}, session_id=sid)
|
|
487
|
+
object_id = (((await send.DOM.resolveNode(params={"backendNodeId": backend}, session_id=sid)) or {}).get("object") or {}).get("objectId")
|
|
488
|
+
if not object_id:
|
|
489
|
+
return out
|
|
490
|
+
tree = await send.Accessibility.getPartialAXTree(params={"objectId": object_id, "fetchRelatives": False}, session_id=sid)
|
|
491
|
+
nodes = [n for n in tree.get("nodes") or [] if not n.get("ignored")]
|
|
492
|
+
if nodes:
|
|
493
|
+
out["role"] = _ax_value(nodes[0].get("role"))[:40]
|
|
494
|
+
out["name"] = " ".join(_ax_value(nodes[0].get("name")).split())[:150]
|
|
495
|
+
dom = ((await send.Runtime.callFunctionOn(params={"objectId": object_id, "functionDeclaration": _IDENTITY_FN, "returnByValue": True}, session_id=sid)) or {}).get("result") or {}
|
|
496
|
+
for k, v in (dom.get("value") or {}).items():
|
|
497
|
+
if k in ("tag", "id", "testid", "href") and isinstance(v, str) and v:
|
|
498
|
+
out[k] = " ".join(v.split())[:200]
|
|
499
|
+
except Exception as ex:
|
|
500
|
+
logger.debug("identity not read: %s", ex)
|
|
501
|
+
return out
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
class Journey:
|
|
505
|
+
"""
|
|
506
|
+
What a keyboard or screen reader persona did, step by step, for a replay with no model (src/a11y/journeys.ts writes
|
|
507
|
+
it as a JavaScript test): each key, swipe, tap and typed text, the page it was on and the page it led to, and what
|
|
508
|
+
it reached (the focus after a key, the item a swipe landed on, the item a tap activated). Typed text that holds a
|
|
509
|
+
saved login's value is kept as that value's name, never the value.
|
|
510
|
+
"""
|
|
511
|
+
|
|
512
|
+
def __init__(self, out_dir: str, persona_id: str, secrets: Optional[Dict[str, str]] = None) -> None:
|
|
513
|
+
self.file = Path(out_dir) / JOURNEY_FILE if out_dir else None
|
|
514
|
+
self.persona = persona_id
|
|
515
|
+
self.steps: List[Dict[str, Any]] = []
|
|
516
|
+
# Longest first, so a value inside another is not named for the shorter one.
|
|
517
|
+
self.secrets = sorted(((n, v) for n, v in (secrets or {}).items() if isinstance(v, str) and len(v) >= 3), key=lambda x: -len(x[1]))
|
|
518
|
+
|
|
519
|
+
def text(self, raw: str) -> Dict[str, str]:
|
|
520
|
+
for name, value in self.secrets:
|
|
521
|
+
if value and value in raw:
|
|
522
|
+
return {"secret": name}
|
|
523
|
+
return {"text": raw[:500]}
|
|
524
|
+
|
|
525
|
+
def add(self, step: Dict[str, Any]) -> None:
|
|
526
|
+
if len(self.steps) >= MAX_JOURNEY or self.file is None:
|
|
527
|
+
return
|
|
528
|
+
self.steps.append(step)
|
|
529
|
+
try:
|
|
530
|
+
self.file.parent.mkdir(parents=True, exist_ok=True)
|
|
531
|
+
self.file.write_text(json.dumps({"persona": self.persona, "steps": self.steps}, indent=1, ensure_ascii=False), encoding="utf-8")
|
|
532
|
+
except OSError as ex:
|
|
533
|
+
logger.warning("%s not written: %s", JOURNEY_FILE, ex)
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
async def _url(browser_session: BrowserSession) -> str:
|
|
537
|
+
try:
|
|
538
|
+
return str(await browser_session.get_current_page_url() or "")[:600]
|
|
539
|
+
except Exception:
|
|
540
|
+
return ""
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
def register_persona_tools(tools: Any, persona: Dict[str, Any], findings: List[Dict[str, Any]], out_dir: str, secrets: Optional[Dict[str, str]] = None) -> None:
|
|
465
544
|
"""record_accessibility_issue always; the keyboard and screen reader actions for a persona that uses them."""
|
|
466
545
|
sighted = uses_vision(persona)
|
|
546
|
+
journey = Journey(out_dir, str(persona.get("id") or ""), secrets)
|
|
467
547
|
|
|
468
548
|
@tools.action(
|
|
469
549
|
"Record one accessibility barrier that this person met, as soon as you meet it: title (a few words), "
|
|
@@ -508,6 +588,7 @@ def register_persona_tools(tools: Any, persona: Dict[str, Any], findings: List[D
|
|
|
508
588
|
return ActionResult(error=f"Not a key this person presses: {raw!r}. Use one of: {', '.join(KEYS)}, Shift+Tab.")
|
|
509
589
|
name = next(k for k, v in KEYS.items() if v is spec)
|
|
510
590
|
k, code, vk, txt = spec
|
|
591
|
+
before = await _url(browser_session)
|
|
511
592
|
try:
|
|
512
593
|
cdp = await _cdp(browser_session)
|
|
513
594
|
send, sid = cdp.cdp_client.send, cdp.session_id
|
|
@@ -518,6 +599,7 @@ def register_persona_tools(tools: Any, persona: Dict[str, Any], findings: List[D
|
|
|
518
599
|
except Exception as ex:
|
|
519
600
|
return ActionResult(error=f"The key was not pressed: {ex}")
|
|
520
601
|
said = f"Pressed {'Shift+' if shift else ''}{name}. {focus_line(f, sighted)}"
|
|
602
|
+
journey.add({"op": "press", "key": f"{'Shift+' if shift else ''}{name}", "url": before, "after": await _url(browser_session), "focus": {} if f.get("none") else await identity(browser_session, active=True)})
|
|
521
603
|
return ActionResult(extracted_content=said, long_term_memory=said)
|
|
522
604
|
|
|
523
605
|
if touch_reader(persona):
|
|
@@ -558,6 +640,8 @@ def register_persona_tools(tools: Any, persona: Dict[str, Any], findings: List[D
|
|
|
558
640
|
if at < 0 or at >= len(items):
|
|
559
641
|
return ActionResult(extracted_content="Start of the page: nothing before this." if at < 0 else "End of the page: nothing after this.")
|
|
560
642
|
cursor.update({"at": at, "line": items[at]["line"], "backend": items[at]["backend"]})
|
|
643
|
+
url = await _url(browser_session)
|
|
644
|
+
journey.add({"op": "swipe", "dir": "next" if step > 0 else "previous", "url": url, "after": url, "item": await identity(browser_session, backend=items[at]["backend"]) if items[at]["backend"] else {"name": str(items[at]["line"])[:150]}})
|
|
561
645
|
said = f"{'Swiped right' if step > 0 else 'Swiped left'}. {items[at]['line']}"
|
|
562
646
|
return ActionResult(extracted_content=said, long_term_memory=said)
|
|
563
647
|
|
|
@@ -573,6 +657,8 @@ def register_persona_tools(tools: Any, persona: Dict[str, Any], findings: List[D
|
|
|
573
657
|
async def double_tap(browser_session: BrowserSession) -> ActionResult:
|
|
574
658
|
if cursor["backend"] is None:
|
|
575
659
|
return ActionResult(error="The cursor is on nothing that can be activated: move to an item with swipe_next first.")
|
|
660
|
+
before = await _url(browser_session)
|
|
661
|
+
target = await identity(browser_session, backend=cursor["backend"])
|
|
576
662
|
try:
|
|
577
663
|
cdp = await _cdp(browser_session)
|
|
578
664
|
send, sid = cdp.cdp_client.send, cdp.session_id
|
|
@@ -596,12 +682,14 @@ def register_persona_tools(tools: Any, persona: Dict[str, Any], findings: List[D
|
|
|
596
682
|
except Exception as ex:
|
|
597
683
|
return ActionResult(error=f"Double tap did not reach {cursor['line']}: {ex}")
|
|
598
684
|
said = f"Double tapped {cursor['line']}. {focus_line(f, False)}"
|
|
685
|
+
journey.add({"op": "tap", "url": before, "after": await _url(browser_session), "target": target, "focus": {} if f.get("none") else await identity(browser_session, active=True)})
|
|
599
686
|
return ActionResult(extracted_content=said, long_term_memory=said)
|
|
600
687
|
|
|
601
688
|
if touch_reader(persona) or keyboard_only(persona):
|
|
602
689
|
|
|
603
690
|
@tools.action("Type text into the field that has focus, as on the on-screen or a real keyboard. Put focus in the field first (press_key, or double_tap on a touchscreen).")
|
|
604
691
|
async def type_text(text: str, browser_session: BrowserSession) -> ActionResult:
|
|
692
|
+
before = await _url(browser_session)
|
|
605
693
|
try:
|
|
606
694
|
f = await focused(browser_session)
|
|
607
695
|
if f.get("none"):
|
|
@@ -611,6 +699,7 @@ def register_persona_tools(tools: Any, persona: Dict[str, Any], findings: List[D
|
|
|
611
699
|
f = await focused(browser_session)
|
|
612
700
|
except Exception as ex:
|
|
613
701
|
return ActionResult(error=f"Not typed: {ex}")
|
|
702
|
+
journey.add({"op": "type", **journey.text(str(text or "")), "url": before, "after": await _url(browser_session), "focus": await identity(browser_session, active=True)})
|
|
614
703
|
said = f"Typed into {f.get('announce', 'the field')}."
|
|
615
704
|
return ActionResult(extracted_content=said, long_term_memory=said)
|
|
616
705
|
|