@capagents/forgeqe 3.2.6 → 3.2.8
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 +4 -1
- package/dist/docs-site/CREDITS.md +3 -3
- package/dist/docs-site/{LICENSE.dm-sans.txt → LICENSE.geist.txt} +1 -1
- package/dist/docs-site/app-look.css +72 -32
- package/dist/docs-site/architecture-map/arch-theme.css +31 -40
- package/dist/docs-site/docs/app-theme.css +109 -108
- package/dist/docs-site/docs/area-api/index.html +3 -3
- package/dist/docs-site/docs/area-browser/index.html +2 -0
- package/dist/docs-site/docs/area-setup/index.html +1 -0
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/docs-site/docs/web-app/index.html +2 -2
- package/dist/docs-site/security/security-theme.css +66 -69
- package/dist/forgeqe.js +1870 -1847
- package/dist/web/THIRD_PARTY_NOTICES.md +0 -101
- package/dist/web/assets/{3d-force-graph-CNVqakzA.js → 3d-force-graph-CbGbqGhp.js} +1 -1
- package/dist/web/assets/Agent-g57O0gf2.js +8 -0
- package/dist/web/assets/AgentWork-DEZxLOeM.js +2 -0
- package/dist/web/assets/ApiTests-DhxqD5GK.js +15 -0
- package/dist/web/assets/Browse-DfvSk_5f.js +1 -0
- package/dist/web/assets/Chat-CuuX_MnF.js +3 -0
- package/dist/web/assets/CommandPalette-DLXhO1e4.js +1 -0
- package/dist/web/assets/Compare-DFRzCXyA.js +1 -0
- package/dist/web/assets/Cost-CZ1xMPze.js +1 -0
- package/dist/web/assets/Data-jxeBry5m.js +6 -0
- package/dist/web/assets/Desktop-4S45Nhc5.js +1 -0
- package/dist/web/assets/DesktopReview-CUyNT0Hl.js +2 -0
- package/dist/web/assets/DeviceScreen-DlJqIxZ-.js +1 -0
- package/dist/web/assets/Evidence-BP-fY7HX.js +1 -0
- package/dist/web/assets/Explore-DY5e98Jz.js +2 -0
- package/dist/web/assets/Features-CKpQ7ilm.js +1 -0
- package/dist/web/assets/Flags-CLm40jFw.js +2 -0
- package/dist/web/assets/Flaky-CQx5RPZt.js +1 -0
- package/dist/web/assets/Impact-DsvECtFV.js +3 -0
- package/dist/web/assets/Jobs-Dzgeugby.js +5 -0
- package/dist/web/assets/KindPage-Dy8mhe14.js +6 -0
- package/dist/web/assets/LiveDevice-DGXIulGh.js +1 -0
- package/dist/web/assets/Migration-ecdFw6JR.js +8 -0
- package/dist/web/assets/Mobile-89JRhyfb.js +1 -0
- package/dist/web/assets/Observability-BTxPNYcK.js +1 -0
- package/dist/web/assets/PageAgent-CtHfmMj1.js +1 -0
- package/dist/web/assets/Product-DutzjAnI.js +12 -0
- package/dist/web/assets/Production-DVc4vly0.js +1 -0
- package/dist/web/assets/Quality-DDRPOOgr.js +1 -0
- package/dist/web/assets/Readiness-BRtsOnY7.js +1 -0
- package/dist/web/assets/Record-BgX9IgVU.js +1 -0
- package/dist/web/assets/Regression-B5TZmljh.js +5 -0
- package/dist/web/assets/RelationGraph-Bf7JxnoO.js +1 -0
- package/dist/web/assets/Reports-Ckul-6_Z.js +2 -0
- package/dist/web/assets/Responsive-BuFvnY-7.js +3 -0
- package/dist/web/assets/RunDiff-lbzcjQPB.js +1 -0
- package/dist/web/assets/Settings-DICPHvyS.js +21 -0
- package/dist/web/assets/Steps-Bgta9n5a.js +3 -0
- package/dist/web/assets/TestData-DhzYxkRb.js +2 -0
- package/dist/web/assets/TestManagement-DOTikKBJ.js +4 -0
- package/dist/web/assets/WhatsNew-BNpscacD.js +1 -0
- package/dist/web/assets/agentSettingsSheet-CE2-cOUE.js +1 -0
- package/dist/web/assets/choice-DPE-97iI.js +1 -0
- package/dist/web/assets/code-DzYywAs5.js +1 -0
- package/dist/web/assets/{coverage-xSRsKFL6.js → coverage-8y4Ntf5j.js} +3 -3
- package/dist/web/assets/dataParts-BWLBAktB.js +3 -0
- package/dist/web/assets/desktopAppPath-CNgKUGx-.js +1 -0
- package/dist/web/assets/frame-CILGAQMi.js +13 -0
- package/dist/web/assets/index-CAiu49as.css +2 -0
- package/dist/web/assets/index-jQktxp_0.js +56 -0
- package/dist/web/assets/markdown-C3_rYFsI.js +8 -0
- package/dist/web/assets/pageBack-CpPsn9m9.js +3 -0
- package/dist/web/assets/palette-B4gvOIk7.js +1 -0
- package/dist/web/assets/{paletteCommands-CwHwpVqt.js → paletteCommands-Df6J2Ddx.js} +1 -1
- package/dist/web/assets/parts-CoaptHZw.js +1 -0
- package/dist/web/assets/preload-helper-Bjdk4wEa.js +1 -0
- package/dist/web/assets/productParts-yX7pkb5g.js +1 -0
- package/dist/web/assets/qualityParts-DfUjhv4u.js +1 -0
- package/dist/web/assets/radio-BerZ8bce.js +1 -0
- package/dist/web/assets/recordTest-CYjGtHjQ.js +1 -0
- package/dist/web/assets/route-M6BKgobp.js +1 -0
- package/dist/web/assets/{sectionList-BlwEtA8S.js → sectionList-K06uJ9W7.js} +1 -1
- package/dist/web/assets/stepper-yRhSVs0I.js +1 -0
- package/dist/web/index.html +10 -9
- package/docs/WEB_APP.md +2 -2
- package/docs/user-guide.html +13 -7
- package/package.json +1 -1
- package/prompts/api-scenarios.md +1 -0
- package/prompts/brain.md +1 -0
- package/py/forgeqe_desktop/replay.py +3 -1
- package/py/forgeqe_desktop/workflow.py +19 -0
- package/py/forgeqe_engine/capture.py +19 -4
- package/py/forgeqe_engine/cli.py +12 -10
- package/py/forgeqe_engine/clientcert.py +28 -0
- package/py/forgeqe_engine/d365.py +182 -0
- package/py/forgeqe_engine/logins.py +20 -16
- package/py/forgeqe_engine/memory.py +9 -3
- package/py/forgeqe_engine/recordsession.py +23 -3
- package/py/forgeqe_engine/webrecord.py +16 -0
- package/py/forgeqe_engine/webrecord_page.py +26 -1
- package/py/forgeqe_mobile/appium_driver.py +26 -0
- package/py/forgeqe_mobile/maestro.py +2 -1
- package/dist/web/assets/Agent-CAp1dIHx.js +0 -8
- package/dist/web/assets/AgentWork-DxO8FN6U.js +0 -2
- package/dist/web/assets/ApiTests-XQ8wXCBj.js +0 -14
- package/dist/web/assets/Browse-BP1oToo4.js +0 -1
- package/dist/web/assets/Chat-DjIdHvHj.js +0 -3
- package/dist/web/assets/CommandPalette-rNWxEO_C.js +0 -1
- package/dist/web/assets/Compare-DwUP21-2.js +0 -1
- package/dist/web/assets/Cost-qZ-gGn2T.js +0 -1
- package/dist/web/assets/Data-AlbKk5zW.js +0 -6
- package/dist/web/assets/Desktop-yGPlxyBz.js +0 -1
- package/dist/web/assets/DesktopReview-BlpxN07L.js +0 -2
- package/dist/web/assets/DeviceScreen-BQKsJonx.js +0 -1
- package/dist/web/assets/Evidence-BCodp0GV.js +0 -1
- package/dist/web/assets/Explore-Ck5EEDy7.js +0 -2
- package/dist/web/assets/Features-BOQomaU8.js +0 -1
- package/dist/web/assets/Flags-DjolLE4S.js +0 -2
- package/dist/web/assets/Flaky-D-xnPfil.js +0 -1
- package/dist/web/assets/Impact-CoNLaNwy.js +0 -3
- package/dist/web/assets/Jobs-_kBd2W3F.js +0 -5
- package/dist/web/assets/KindPage-DfnkzpPj.js +0 -6
- package/dist/web/assets/LiveDevice-DRAN4Gl4.js +0 -1
- package/dist/web/assets/Migration-PETc1Ckc.js +0 -8
- package/dist/web/assets/Mobile-B193VBXu.js +0 -1
- package/dist/web/assets/Observability-CvdV37XD.js +0 -1
- package/dist/web/assets/PageAgent-BJguufGW.js +0 -1
- package/dist/web/assets/Product-Cmgcj9fr.js +0 -12
- package/dist/web/assets/Production-DM62n03j.js +0 -1
- package/dist/web/assets/Quality-DbgAAeel.js +0 -1
- package/dist/web/assets/Readiness-CojmD235.js +0 -1
- package/dist/web/assets/Record-C4VFM97k.js +0 -1
- package/dist/web/assets/Regression-5mma_vyD.js +0 -5
- package/dist/web/assets/RelationGraph-bDvvcead.js +0 -1
- package/dist/web/assets/Reports-BeSrlzKk.js +0 -2
- package/dist/web/assets/Responsive-B4CkMBwF.js +0 -3
- package/dist/web/assets/RunDiff-DGThx7bk.js +0 -1
- package/dist/web/assets/Settings-IjfPYiuf.js +0 -21
- package/dist/web/assets/Steps-BPSNI3aY.js +0 -3
- package/dist/web/assets/TestCases-hIuP5BLu.js +0 -1
- package/dist/web/assets/TestData-DpAMEMLP.js +0 -2
- package/dist/web/assets/TestDebt-D6UjJCpY.js +0 -1
- package/dist/web/assets/TestManagement-CTWh-aA8.js +0 -4
- package/dist/web/assets/WhatsNew-DMDg1zmv.js +0 -1
- package/dist/web/assets/agentSettingsSheet-CUogAKga.js +0 -1
- package/dist/web/assets/dataParts-s8iIR3Ad.js +0 -3
- package/dist/web/assets/desktopAppPath-CnmfVr-s.js +0 -1
- package/dist/web/assets/dm-sans-latin-400-normal-BwCSEQnW.woff +0 -0
- package/dist/web/assets/dm-sans-latin-400-normal-CW0RaeGs.woff2 +0 -0
- package/dist/web/assets/dm-sans-latin-500-normal-B9HHJjqV.woff2 +0 -0
- package/dist/web/assets/dm-sans-latin-500-normal-Dr3UlScf.woff +0 -0
- package/dist/web/assets/dm-sans-latin-600-normal-Aqo67rzb.woff2 +0 -0
- package/dist/web/assets/dm-sans-latin-600-normal-BmdmIIQ2.woff +0 -0
- package/dist/web/assets/dm-sans-latin-ext-400-normal-BjWJ59Pq.woff +0 -0
- package/dist/web/assets/dm-sans-latin-ext-400-normal-BtiwyxMk.woff2 +0 -0
- package/dist/web/assets/dm-sans-latin-ext-500-normal-BJfUCQsA.woff2 +0 -0
- package/dist/web/assets/dm-sans-latin-ext-500-normal-DR84L5F-.woff +0 -0
- package/dist/web/assets/dm-sans-latin-ext-600-normal-4vooXBpG.woff2 +0 -0
- package/dist/web/assets/dm-sans-latin-ext-600-normal-DRtaDpgU.woff +0 -0
- package/dist/web/assets/frame-DNgVKrlp.js +0 -13
- package/dist/web/assets/index-BBJ_SKdO.js +0 -56
- package/dist/web/assets/index-hysPD6U9.css +0 -2
- package/dist/web/assets/input-FbzQKk3L.js +0 -1
- package/dist/web/assets/markdown-1z66EzBR.js +0 -8
- package/dist/web/assets/pageBack-B6bY6ZUl.js +0 -3
- package/dist/web/assets/palette-C5Ok5Zd1.js +0 -1
- package/dist/web/assets/parts-Dqq6noWp.js +0 -1
- package/dist/web/assets/productParts-DNSo4bn5.js +0 -1
- package/dist/web/assets/qualityParts-kh6SukEP.js +0 -1
- package/dist/web/assets/recordTest-BCxsm3gC.js +0 -1
- package/dist/web/assets/route-D8G-pTdk.js +0 -1
- package/dist/web/assets/stepper-ByKrM1LP.js +0 -1
|
@@ -31,7 +31,9 @@ from types import SimpleNamespace
|
|
|
31
31
|
from typing import Any, Awaitable, Callable, Dict, List, Optional, Set, Tuple
|
|
32
32
|
|
|
33
33
|
from .capture import capture_element, element_facts_cdp, locate_check
|
|
34
|
+
from .clientcert import client_cert_host
|
|
34
35
|
from .network import NetworkCapture
|
|
36
|
+
from .d365 import ATTRS as D365_ATTRS, clean_facts as d365_clean_facts, note as d365_note
|
|
35
37
|
from .memory import BASE, KEPT_ATTRS, MAX_REL_XPATH, candidate_locators, confidence, looks_generated, split_state, state_class, state_word, within_locator
|
|
36
38
|
from . import dynamic
|
|
37
39
|
from .varying import SeenElements, mark as mark_varying
|
|
@@ -578,6 +580,13 @@ class RecordSession:
|
|
|
578
580
|
await self._navigated(event, sid, same=kind == "navigated_same")
|
|
579
581
|
elif kind == "request":
|
|
580
582
|
self._capture_request(event, sid)
|
|
583
|
+
# Entra's device sign-in: Chrome asks the person for a certificate in a box of its own (clientcert.py).
|
|
584
|
+
cert_host = client_cert_host(str((event.get("request") or {}).get("url") or ""))
|
|
585
|
+
if cert_host and self.rec is not None:
|
|
586
|
+
msg = self.rec.on_client_certificate(cert_host)
|
|
587
|
+
if msg:
|
|
588
|
+
self._changed(msg)
|
|
589
|
+
self.log("Chrome asks for this computer's device certificate (its own box, outside the page): pick it there. The recording keeps it as a step; a replay picks it by Chrome's policy (forgeqe doctor certificate).")
|
|
581
590
|
if event.get("type") in ("XHR", "Fetch") and event.get("requestId"):
|
|
582
591
|
if len(self._requests) > 2000:
|
|
583
592
|
self._requests.clear()
|
|
@@ -1172,14 +1181,17 @@ class RecordSession:
|
|
|
1172
1181
|
target = Target(url, live.facts, counted_at_event(live.locators, data["matches"]), live.frames, closed_shadow=closed)
|
|
1173
1182
|
# None of its own locators unique: the one anchored on its container (the page script counted it), where there is one.
|
|
1174
1183
|
anchored = within_locator(data.get("anchor"))
|
|
1175
|
-
if anchored and generic_name(target.facts) and not any(l.get("type") in ("test_id", "id") and l.get("verified") for l in target.locators):
|
|
1184
|
+
if anchored and generic_name(target.facts) and not any((l.get("type") in ("test_id", "id") or l.get("site") == "d365") and l.get("verified") for l in target.locators):
|
|
1176
1185
|
# A name many controls share ("Close" of a toast): another like it may show on a replay; its container first.
|
|
1177
1186
|
locs = [anchored] + [l for l in target.locators if l.get("type") != "within"]
|
|
1178
1187
|
target = Target(target.url, target.facts, locs, target.frames, closed_shadow=target.closed_shadow)
|
|
1179
|
-
elif anchored and not any(l.get("verified") and l.get("matches") == 1 and l.get("type") in STRONG_ALONE for l in target.locators):
|
|
1188
|
+
elif anchored and not any(l.get("verified") and l.get("matches") == 1 and (l.get("type") in STRONG_ALONE or l.get("site") == "d365") for l in target.locators):
|
|
1180
1189
|
locs = sorted(target.locators + [anchored], key=lambda l: (not l.get("verified"), -int(l.get("confidence") or 0)))
|
|
1181
1190
|
target = Target(target.url, target.facts, locs, target.frames, closed_shadow=target.closed_shadow)
|
|
1182
1191
|
target = await self._steady(sid, target, data.get("matches") if isinstance(data.get("matches"), dict) else {}, ctx=ctx)
|
|
1192
|
+
if target.facts.get("site") == "d365" and not getattr(self, "_d365_said", False):
|
|
1193
|
+
self._d365_said = True
|
|
1194
|
+
self.log(d365_note())
|
|
1183
1195
|
return self._varying(sid, target)
|
|
1184
1196
|
|
|
1185
1197
|
def _varying(self, sid: str, t: Target) -> Target:
|
|
@@ -1989,6 +2001,11 @@ def _count(loc: Dict[str, Any], counted: Dict[str, Any]) -> Optional[int]:
|
|
|
1989
2001
|
"""How many elements the page script counted for a locator of this kind, at the event; None when it did not count."""
|
|
1990
2002
|
kind = loc.get("type")
|
|
1991
2003
|
attrs = counted.get("attr") or {}
|
|
2004
|
+
if kind == "css" and loc.get("site") == "d365":
|
|
2005
|
+
# A D365 control's selector (d365.py): counted through the one attribute it narrows, an upper bound; the
|
|
2006
|
+
# control around the element (`up`) was not counted at all.
|
|
2007
|
+
n = attrs.get(loc["count_attr"]) if loc.get("count_attr") and not loc.get("up") else None
|
|
2008
|
+
return n if isinstance(n, int) and not isinstance(n, bool) and n >= 0 else None
|
|
1992
2009
|
if kind == "test_id":
|
|
1993
2010
|
n = attrs.get(loc.get("attr") or "data-testid")
|
|
1994
2011
|
elif kind == "id":
|
|
@@ -2187,12 +2204,15 @@ def fallback_target(url: str, facts: Dict[str, Any], counted: Optional[Dict[str,
|
|
|
2187
2204
|
A locator the page script counted as matching exactly one element then is verified, as one checked over the
|
|
2188
2205
|
DevTools protocol is.
|
|
2189
2206
|
"""
|
|
2207
|
+
d365 = d365_clean_facts({"site": facts.get("site"), "attributes": facts.get("attributes") or {}, "d365_up": facts.get("d365_up")})
|
|
2190
2208
|
f = {
|
|
2209
|
+
**({"site": d365["site"]} if d365.get("site") else {}),
|
|
2210
|
+
**({"d365_up": d365["d365_up"]} if d365.get("d365_up") else {}),
|
|
2191
2211
|
"tag": str(facts.get("tag") or ""),
|
|
2192
2212
|
"role": str(facts.get("role") or ""),
|
|
2193
2213
|
"name": " ".join(str(facts.get("name") or "").split())[:120],
|
|
2194
2214
|
"text": " ".join(str(facts.get("text") or "").split())[:120],
|
|
2195
|
-
"attributes": {k: str(v) for k, v in
|
|
2215
|
+
"attributes": {k: str(v) for k, v in d365["attributes"].items() if (k in KEPT_ATTRS or k in D365_ATTRS) and v},
|
|
2196
2216
|
"classes": [c for c in facts.get("classes") or [] if isinstance(c, str) and not looks_generated(c) and not state_class(c)][:4],
|
|
2197
2217
|
"xpath": str(facts.get("xpath") or ""),
|
|
2198
2218
|
"rel_xpath": str(facts.get("rel_xpath") or "")[:MAX_REL_XPATH],
|
|
@@ -29,6 +29,7 @@ from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple
|
|
|
29
29
|
from urllib.parse import urlparse
|
|
30
30
|
|
|
31
31
|
from . import dynamic
|
|
32
|
+
from .clientcert import CLIENT_CERT_HOSTS
|
|
32
33
|
from .memory import FLOW_STEP_LOCATORS, TEST_ID_ATTRS, element_label, looks_generated, page_id
|
|
33
34
|
|
|
34
35
|
FORMAT_SOURCE = "recorded"
|
|
@@ -348,6 +349,8 @@ def describe(step: Dict[str, Any]) -> str:
|
|
|
348
349
|
return f"wait for {label}"
|
|
349
350
|
if op == "captcha":
|
|
350
351
|
return f"solve the {step.get('provider') or 'CAPTCHA'} (a person; a test turns it off)"
|
|
352
|
+
if op == "client_certificate":
|
|
353
|
+
return f"pick this computer's certificate ({step.get('issuer')}) in Chrome's box for {step.get('host')} (a replay: Chrome's policy)"
|
|
351
354
|
if op == "dialog":
|
|
352
355
|
return dialog_words(step)
|
|
353
356
|
if op == "scroll":
|
|
@@ -580,6 +583,19 @@ class WebRecorder:
|
|
|
580
583
|
self._add({"op": "captcha", "provider": provider, "page": page_id(self.url) or self.url})
|
|
581
584
|
return describe(self.steps[-1])
|
|
582
585
|
|
|
586
|
+
def on_client_certificate(self, host: str) -> Optional[str]:
|
|
587
|
+
"""
|
|
588
|
+
Chrome asked for a client certificate for `host` (clientcert.py): one `client_certificate` step, once per host in a
|
|
589
|
+
recording, by host and the issuer of the certificate that answers, both of CLIENT_CERT_HOSTS.
|
|
590
|
+
"""
|
|
591
|
+
issuer = CLIENT_CERT_HOSTS.get(host)
|
|
592
|
+
if self.paused or not issuer:
|
|
593
|
+
return None
|
|
594
|
+
if any(s.get("op") == "client_certificate" and s.get("host") == host for s in self.steps):
|
|
595
|
+
return None
|
|
596
|
+
self._add({"op": "client_certificate", "host": host, "issuer": issuer, "page": page_id(self.url) or self.url})
|
|
597
|
+
return describe(self.steps[-1])
|
|
598
|
+
|
|
583
599
|
def on_download(self, name: Any, size: Optional[int] = None) -> Optional[str]:
|
|
584
600
|
"""
|
|
585
601
|
A file the page downloaded after the step before (an "Export CSV" button): a step that checks a file of that
|
|
@@ -14,6 +14,7 @@ from __future__ import annotations
|
|
|
14
14
|
import json
|
|
15
15
|
from typing import Any, Dict, Optional
|
|
16
16
|
|
|
17
|
+
from .d365 import page_config as d365_page_config
|
|
17
18
|
from .memory import SHAKY_TEXT, STATE_CLASS, STATE_NAME, TEXT_GEN
|
|
18
19
|
|
|
19
20
|
# The leader key, then one letter: what each letter does, as the key bar and the panel's hint show it.
|
|
@@ -182,6 +183,8 @@ RECORDER_JS = r"""(() => {
|
|
|
182
183
|
for (const k of XP_ATTRS) {
|
|
183
184
|
const v = f.attributes[k];
|
|
184
185
|
if (!v || v.length > 120 || XP_GEN.test(v)) continue;
|
|
186
|
+
// An id D365 renders from where the control sits (AppModuleTileSec_1_Item_1, d365.py GENERATED): never an anchor.
|
|
187
|
+
if (f.site === 'd365' && (k === 'id' || k === 'name') && D365_GEN.test(v)) continue;
|
|
185
188
|
const stem = stemOf(norm(v));
|
|
186
189
|
return stem ? '[starts-with(normalize-space(@' + k + '), ' + xpLit(stem) + ')]' : '[@' + k + '=' + xpLit(v) + ']';
|
|
187
190
|
}
|
|
@@ -219,13 +222,35 @@ RECORDER_JS = r"""(() => {
|
|
|
219
222
|
// (memory.py class_selector, which writes the same selector).
|
|
220
223
|
const CSS_MODULE = /^([A-Z][A-Za-z0-9]*_[A-Za-z][A-Za-z0-9]*__)(?=[A-Za-z0-9_-]*[0-9A-Z])[A-Za-z0-9_-]{4,10}$/;
|
|
221
224
|
const classSel = (c) => { const m = CSS_MODULE.exec(c); return m ? '[class*="' + m[1] + '"]' : '.' + c; };
|
|
225
|
+
// ---- Dynamics 365 (d365.py, ADO 3529) ---------------------------------------------------------------------------
|
|
226
|
+
// On a D365 page its own attributes are read too (data-id, data-lp-id, data-type, data-control-name), as the
|
|
227
|
+
// dynamics-365 skill names its controls, and the D365 control an element is inside (a click on an app tile's name).
|
|
228
|
+
const D365 = CFG.d365 || null;
|
|
229
|
+
const D365_GEN = D365 ? new RegExp(D365.gen, 'i') : /$^/;
|
|
230
|
+
const isD365 = () => { try { return !!D365 && (new RegExp(D365.host, 'i').test(location.hostname) || !!document.getElementById(D365.shell)); } catch (err) { return false; } };
|
|
231
|
+
const d365Attrs = (x) => {
|
|
232
|
+
const a = {};
|
|
233
|
+
for (const k of D365.attrs) { const v = x.getAttribute(k); if (v) a[k] = v.slice(0, 200); }
|
|
234
|
+
if (a['data-type'] && a['data-type'] !== 'app-title') delete a['data-type'];
|
|
235
|
+
return a;
|
|
236
|
+
};
|
|
237
|
+
const d365Up = (e) => {
|
|
238
|
+
for (let x = up(e), i = 0; x && x.nodeType === 1 && i < D365.up && x !== document.body; x = up(x), i++) {
|
|
239
|
+
const a = d365Attrs(x);
|
|
240
|
+
if (Object.keys(a).length) { const t = x.getAttribute('title'); if (t) a.title = t.slice(0, 200); return { tag: x.tagName.toLowerCase(), attributes: a }; }
|
|
241
|
+
}
|
|
242
|
+
return null;
|
|
243
|
+
};
|
|
222
244
|
const facts = (e) => {
|
|
223
245
|
const attrs = {};
|
|
224
246
|
for (const k of CFG.kept) { const v = e.getAttribute(k); if (v) attrs[k] = v; }
|
|
247
|
+
const d365 = isD365();
|
|
248
|
+
if (d365) Object.assign(attrs, d365Attrs(e));
|
|
225
249
|
const name = accName(e);
|
|
226
250
|
// Never a state class (active, selected, is-open): it moves to another element (memory.py STATE_CLASS).
|
|
227
251
|
const classes = [...e.classList].filter((c) => /^[A-Za-z_-][\w-]*$/.test(c) && !STATE_CLASS.test(c)).slice(0, 4);
|
|
228
252
|
const f = { tag: e.tagName.toLowerCase(), attributes: attrs, classes, xpath: xpath(e), role: e.getAttribute('role') || implicitRole(e), name: name.slice(0, 120), text: name ? '' : textOf(e).slice(0, 120) };
|
|
253
|
+
if (d365) { f.site = 'd365'; const u = d365Up(e); if (u) f.d365_up = u; }
|
|
229
254
|
const rel = relXpath(e, f);
|
|
230
255
|
if (rel) f.rel_xpath = rel;
|
|
231
256
|
return f;
|
|
@@ -1242,5 +1267,5 @@ def recorder_js(binding: str, kept: Any, *, leader: Dict[str, Any], badge: bool
|
|
|
1242
1267
|
The page script; ``badge``: no panel, only a badge that says it records (a recording started from the web app);
|
|
1243
1268
|
``pw``: the saved logins' password fingerprints for this recording (recordsession.password_prints), never a password.
|
|
1244
1269
|
"""
|
|
1245
|
-
config = {"binding": binding, "kept": list(kept), "leader": leader, "commands": [list(c) for c in COMMAND_KEYS], "badge": bool(badge), "stateClass": STATE_CLASS, "stateName": STATE_NAME, "textGen": TEXT_GEN, "shakyText": SHAKY_TEXT, **({"pw": pw} if pw else {})}
|
|
1270
|
+
config = {"binding": binding, "kept": list(kept), "leader": leader, "commands": [list(c) for c in COMMAND_KEYS], "badge": bool(badge), "stateClass": STATE_CLASS, "stateName": STATE_NAME, "textGen": TEXT_GEN, "shakyText": SHAKY_TEXT, "d365": d365_page_config(), **({"pw": pw} if pw else {})}
|
|
1246
1271
|
return RECORDER_JS.replace("__CONFIG__", json.dumps(config))
|
|
@@ -44,6 +44,29 @@ class AppiumError(RuntimeError):
|
|
|
44
44
|
"""The Appium server refused a command or could not be reached; the message says which."""
|
|
45
45
|
|
|
46
46
|
|
|
47
|
+
# TestMu AI (LambdaTest) refuses a session its account's plan does not cover, e.g. "Native App Automation Virtual not
|
|
48
|
+
# allowed on your current plan". That is the account's setup, not the app: say what to change instead of a bare 400.
|
|
49
|
+
_PLAN_REFUSAL = re.compile(r"not allowed on your (?:current )?plan", re.IGNORECASE)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _testmu_plan_refusal(message: str, lt: Any) -> Optional[str]:
|
|
53
|
+
"""An actionable message when TestMu refused the session for the account's plan; None for any other refusal."""
|
|
54
|
+
if not _PLAN_REFUSAL.search(message):
|
|
55
|
+
return None
|
|
56
|
+
virtual = isinstance(lt, dict) and lt.get("isRealMobile") is False
|
|
57
|
+
kind = "virtual devices (emulators and simulators)" if virtual else "real devices"
|
|
58
|
+
other = (
|
|
59
|
+
"use a real device instead (type: real, or \"isRealMobile\": true in LT:Options)"
|
|
60
|
+
if virtual
|
|
61
|
+
else "use a virtual device instead (type: virtual, or \"isRealMobile\": false in LT:Options)"
|
|
62
|
+
)
|
|
63
|
+
return (
|
|
64
|
+
f"TestMu refused to start the app: your TestMu plan does not include App Automation on {kind}, so nothing was "
|
|
65
|
+
f"run and the app was not launched. This is the TestMu account's setup, not a fault in the app. Either {other} "
|
|
66
|
+
"if your plan has it, or ask TestMu to add it to your plan (https://www.lambdatest.com/pricing), then replay again."
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
47
70
|
# Appium's name for the app's own screen, as opposed to a web page inside it (WEBVIEW_…).
|
|
48
71
|
NATIVE = "NATIVE_APP"
|
|
49
72
|
|
|
@@ -438,6 +461,9 @@ class AppiumDriver:
|
|
|
438
461
|
value = self._call("POST", "/session", {"capabilities": {"alwaysMatch": caps, "firstMatch": [{}]}}, timeout=wait)
|
|
439
462
|
except AppiumError as e:
|
|
440
463
|
lt = caps.get("LT:Options")
|
|
464
|
+
plan = _testmu_plan_refusal(str(e), lt)
|
|
465
|
+
if plan:
|
|
466
|
+
raise AppiumError(plan) from None
|
|
441
467
|
if isinstance(lt, dict) and lt.get("isRealMobile") is False and "not supported" in str(e):
|
|
442
468
|
# TestMu's emulators and simulators are a list of their own, which no API lists.
|
|
443
469
|
raise AppiumError(
|
|
@@ -23,7 +23,7 @@ from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Seque
|
|
|
23
23
|
|
|
24
24
|
import yaml
|
|
25
25
|
|
|
26
|
-
from forgeqe_desktop.workflow import WorkflowError, fill, fill_targets, secret_names, validate
|
|
26
|
+
from forgeqe_desktop.workflow import WorkflowError, fill, fill_targets, new_run_unique, secret_names, validate
|
|
27
27
|
|
|
28
28
|
_JS_EXPR = re.compile(r"\$\{([^}]*)\}")
|
|
29
29
|
_JS_VAR = re.compile(r"^\s*[A-Za-z_][A-Za-z0-9_]*\s*$")
|
|
@@ -88,6 +88,7 @@ def _ms(seconds: Any) -> int:
|
|
|
88
88
|
def to_flow(workflow: Mapping[str, Any], app_id: str, variables: Optional[Mapping[str, Any]] = None, allowed_secrets: Iterable[str] = ()) -> Tuple[str, List[str]]:
|
|
89
89
|
"""``(flow text, secret names)`` for a mobile workflow; the secrets are read from MAESTRO_<NAME> when it runs."""
|
|
90
90
|
wf = validate(dict(workflow))
|
|
91
|
+
new_run_unique()
|
|
91
92
|
if wf["format"] != "forgeqe-mobile-v1":
|
|
92
93
|
raise WorkflowError("only mobile workflows (forgeqe-mobile-v1) run on Maestro")
|
|
93
94
|
allowed = {str(n) for n in allowed_secrets}
|