@capagents/forgeqe 3.2.5 → 3.2.7

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.
Files changed (176) hide show
  1. package/HOW_TO_USE.md +12 -5
  2. package/dist/docs-site/CREDITS.md +3 -3
  3. package/dist/docs-site/{LICENSE.dm-sans.txt → LICENSE.geist.txt} +1 -1
  4. package/dist/docs-site/app-look.css +72 -32
  5. package/dist/docs-site/architecture-map/arch-theme.css +31 -40
  6. package/dist/docs-site/docs/app-theme.css +109 -108
  7. package/dist/docs-site/docs/architecture-reference/index.html +1 -0
  8. package/dist/docs-site/docs/area-api/index.html +17 -4
  9. package/dist/docs-site/docs/area-browser/index.html +2 -0
  10. package/dist/docs-site/docs/area-setup/index.html +1 -0
  11. package/dist/docs-site/docs/get-started/index.html +7 -4
  12. package/dist/docs-site/docs/overview/index.html +1 -1
  13. package/dist/docs-site/docs/search.js +1 -1
  14. package/dist/docs-site/docs/web-app/index.html +6 -3
  15. package/dist/docs-site/security/security-theme.css +66 -69
  16. package/dist/forgeqe.js +1890 -1860
  17. package/dist/web/THIRD_PARTY_NOTICES.md +0 -101
  18. package/dist/web/assets/{3d-force-graph-D62h_vvb.js → 3d-force-graph-CUGt_TSW.js} +1 -1
  19. package/dist/web/assets/Agent-DiX8ljlC.js +8 -0
  20. package/dist/web/assets/AgentWork-BpfMY_xu.js +2 -0
  21. package/dist/web/assets/ApiTests-4jfzlfVd.js +15 -0
  22. package/dist/web/assets/Browse-ByDemInL.js +1 -0
  23. package/dist/web/assets/Chat-C3wKV0CI.js +3 -0
  24. package/dist/web/assets/CommandPalette-CKJHtRjo.js +1 -0
  25. package/dist/web/assets/Compare-DtW2g-qb.js +1 -0
  26. package/dist/web/assets/Cost-DW-kVEL8.js +1 -0
  27. package/dist/web/assets/Data--HGneNun.js +6 -0
  28. package/dist/web/assets/Desktop-DQf5gv7D.js +1 -0
  29. package/dist/web/assets/DesktopReview-BaPYt0kl.js +2 -0
  30. package/dist/web/assets/DeviceScreen-DzVNfMwl.js +1 -0
  31. package/dist/web/assets/Evidence-CxRMnZch.js +1 -0
  32. package/dist/web/assets/Explore-ChpAuezG.js +2 -0
  33. package/dist/web/assets/Features-VsLb8QTH.js +1 -0
  34. package/dist/web/assets/Flags-Do-pvmCF.js +2 -0
  35. package/dist/web/assets/Flaky-CyhTszAg.js +1 -0
  36. package/dist/web/assets/Impact-BWBAXRuw.js +3 -0
  37. package/dist/web/assets/Jobs-C_MjXv0_.js +5 -0
  38. package/dist/web/assets/KindPage-Bb3Kp4-q.js +6 -0
  39. package/dist/web/assets/LiveDevice-OyxEiqBt.js +1 -0
  40. package/dist/web/assets/Migration-C80mGA3h.js +8 -0
  41. package/dist/web/assets/Mobile-C4wVBYfr.js +1 -0
  42. package/dist/web/assets/Observability-DdTOLp2C.js +1 -0
  43. package/dist/web/assets/PageAgent-Bi53-H99.js +1 -0
  44. package/dist/web/assets/Product-0LXndvp-.js +12 -0
  45. package/dist/web/assets/Production-oTXhv40a.js +1 -0
  46. package/dist/web/assets/Quality-CY0CJF9e.js +1 -0
  47. package/dist/web/assets/Readiness-Bv9uTTiI.js +1 -0
  48. package/dist/web/assets/Record-C-kyOkYq.js +1 -0
  49. package/dist/web/assets/Regression-CwKxvG1h.js +5 -0
  50. package/dist/web/assets/RelationGraph-BQl3M4zd.js +1 -0
  51. package/dist/web/assets/Reports-Ck8rc3br.js +2 -0
  52. package/dist/web/assets/Responsive-COmV2NXo.js +3 -0
  53. package/dist/web/assets/RunDiff-BBT1sQLh.js +1 -0
  54. package/dist/web/assets/Settings-7aMk9Sqx.js +21 -0
  55. package/dist/web/assets/Steps-C_vL6-8p.js +3 -0
  56. package/dist/web/assets/TestData-KzMy9N9f.js +2 -0
  57. package/dist/web/assets/TestManagement-BCEhOGB9.js +4 -0
  58. package/dist/web/assets/WhatsNew-DTcaqdOJ.js +1 -0
  59. package/dist/web/assets/agentSettingsSheet-DM1aa237.js +1 -0
  60. package/dist/web/assets/choice-B6z9CWyZ.js +1 -0
  61. package/dist/web/assets/code-DzYywAs5.js +1 -0
  62. package/dist/web/assets/{coverage-xSRsKFL6.js → coverage-BhtF065n.js} +4 -4
  63. package/dist/web/assets/dataParts-BNDVxwFb.js +3 -0
  64. package/dist/web/assets/desktopAppPath-D4hHP56R.js +1 -0
  65. package/dist/web/assets/frame-CNYHTG4T.js +13 -0
  66. package/dist/web/assets/index-B1Q2Dlqw.js +56 -0
  67. package/dist/web/assets/index-sxUpjgyw.css +2 -0
  68. package/dist/web/assets/markdown-BhU7ng6c.js +8 -0
  69. package/dist/web/assets/pageBack-BoSbGSU6.js +3 -0
  70. package/dist/web/assets/palette-BsY8OLxd.js +1 -0
  71. package/dist/web/assets/paletteCommands-DflHQ05x.js +1 -0
  72. package/dist/web/assets/parts-C4QMgN_N.js +1 -0
  73. package/dist/web/assets/preload-helper-qorOEK5q.js +1 -0
  74. package/dist/web/assets/productParts-Dxl-TQKY.js +1 -0
  75. package/dist/web/assets/qualityParts-ClGKtjEv.js +1 -0
  76. package/dist/web/assets/radio-DDxnnflQ.js +1 -0
  77. package/dist/web/assets/recordTest-B33rIncn.js +1 -0
  78. package/dist/web/assets/route-D9uPlFWw.js +1 -0
  79. package/dist/web/assets/sectionList-e5mFDaS2.js +1 -0
  80. package/dist/web/assets/stepper-DSDz0uu8.js +1 -0
  81. package/dist/web/index.html +10 -9
  82. package/docs/ARCHITECTURE_REFERENCE.md +1 -0
  83. package/docs/WEB_APP.md +6 -3
  84. package/docs/user-guide.html +26 -7
  85. package/forgeqe.example.yaml +3 -2
  86. package/llms.example.json +22 -0
  87. package/package.json +1 -1
  88. package/prompts/api-scenarios.md +1 -0
  89. package/prompts/brain.md +1 -0
  90. package/prompts/test-agent.md +0 -2
  91. package/prompts/test-rules.md +3 -8
  92. package/py/forgeqe_desktop/replay.py +48 -1
  93. package/py/forgeqe_desktop/workflow.py +79 -7
  94. package/py/forgeqe_engine/capture.py +19 -4
  95. package/py/forgeqe_engine/cli.py +12 -10
  96. package/py/forgeqe_engine/clientcert.py +28 -0
  97. package/py/forgeqe_engine/copilot_gateway.py +208 -23
  98. package/py/forgeqe_engine/d365.py +182 -0
  99. package/py/forgeqe_engine/logins.py +20 -16
  100. package/py/forgeqe_engine/memory.py +9 -3
  101. package/py/forgeqe_engine/recordsession.py +23 -3
  102. package/py/forgeqe_engine/webrecord.py +16 -0
  103. package/py/forgeqe_engine/webrecord_page.py +26 -1
  104. package/py/forgeqe_mobile/appium_driver.py +26 -0
  105. package/py/forgeqe_mobile/maestro.py +5 -1
  106. package/dist/web/assets/Agent-BadQe1GY.js +0 -8
  107. package/dist/web/assets/AgentWork-BGc6uVxB.js +0 -2
  108. package/dist/web/assets/ApiTests-Bo4ds0wk.js +0 -14
  109. package/dist/web/assets/Browse-CmVZJZ72.js +0 -1
  110. package/dist/web/assets/Chat-LTtQQHqr.js +0 -3
  111. package/dist/web/assets/CommandPalette-Dl_DibqU.js +0 -1
  112. package/dist/web/assets/Compare-Dlzg7S1a.js +0 -1
  113. package/dist/web/assets/Cost-DRKVox_i.js +0 -1
  114. package/dist/web/assets/Data-c2c1QLI9.js +0 -6
  115. package/dist/web/assets/Desktop-BMLYLWq1.js +0 -1
  116. package/dist/web/assets/DesktopReview-CO0vz-8o.js +0 -2
  117. package/dist/web/assets/DeviceScreen-CCDj-wqV.js +0 -1
  118. package/dist/web/assets/Evidence-BQmhYE2G.js +0 -1
  119. package/dist/web/assets/Explore-CVurlUoU.js +0 -2
  120. package/dist/web/assets/Features-DPc3_RSA.js +0 -1
  121. package/dist/web/assets/Flags-D4d9STIv.js +0 -2
  122. package/dist/web/assets/Flaky-Dt3iYOZg.js +0 -1
  123. package/dist/web/assets/Impact-CKy2Ezzt.js +0 -3
  124. package/dist/web/assets/Jobs-BZ4zn_7P.js +0 -5
  125. package/dist/web/assets/KindPage-joSX8gyV.js +0 -6
  126. package/dist/web/assets/LiveDevice-DQNdKoh3.js +0 -1
  127. package/dist/web/assets/Migration-EO--lNV1.js +0 -8
  128. package/dist/web/assets/Mobile-DWGNs3HT.js +0 -1
  129. package/dist/web/assets/Observability-DPjKbwcO.js +0 -1
  130. package/dist/web/assets/PageAgent-h70DL1L7.js +0 -1
  131. package/dist/web/assets/Product-ddlw8A_d.js +0 -12
  132. package/dist/web/assets/Production-svTscJhy.js +0 -1
  133. package/dist/web/assets/Quality-CgIo3fM8.js +0 -1
  134. package/dist/web/assets/Readiness-D6s73wXK.js +0 -1
  135. package/dist/web/assets/Record-Cmzr-0-f.js +0 -1
  136. package/dist/web/assets/Regression--3mygZAw.js +0 -5
  137. package/dist/web/assets/RelationGraph-BZYcwCVA.js +0 -1
  138. package/dist/web/assets/Reports-CDv_x9iB.js +0 -2
  139. package/dist/web/assets/Responsive-BhRYdJlZ.js +0 -3
  140. package/dist/web/assets/RunDiff-CO8asgjK.js +0 -1
  141. package/dist/web/assets/Settings-D3zWorNs.js +0 -21
  142. package/dist/web/assets/Steps-Dn12ePte.js +0 -3
  143. package/dist/web/assets/TestCases-CzXHBm5G.js +0 -1
  144. package/dist/web/assets/TestData-CL9bxSAI.js +0 -2
  145. package/dist/web/assets/TestDebt-B1_-OBJe.js +0 -1
  146. package/dist/web/assets/TestManagement-MwMgDuO_.js +0 -4
  147. package/dist/web/assets/WhatsNew-DLE9LimG.js +0 -1
  148. package/dist/web/assets/agents-DPabR9dS.js +0 -1
  149. package/dist/web/assets/dataParts-DAuDeT2W.js +0 -3
  150. package/dist/web/assets/desktopAppPath-C_bB4dWx.js +0 -1
  151. package/dist/web/assets/dm-sans-latin-400-normal-BwCSEQnW.woff +0 -0
  152. package/dist/web/assets/dm-sans-latin-400-normal-CW0RaeGs.woff2 +0 -0
  153. package/dist/web/assets/dm-sans-latin-500-normal-B9HHJjqV.woff2 +0 -0
  154. package/dist/web/assets/dm-sans-latin-500-normal-Dr3UlScf.woff +0 -0
  155. package/dist/web/assets/dm-sans-latin-600-normal-Aqo67rzb.woff2 +0 -0
  156. package/dist/web/assets/dm-sans-latin-600-normal-BmdmIIQ2.woff +0 -0
  157. package/dist/web/assets/dm-sans-latin-ext-400-normal-BjWJ59Pq.woff +0 -0
  158. package/dist/web/assets/dm-sans-latin-ext-400-normal-BtiwyxMk.woff2 +0 -0
  159. package/dist/web/assets/dm-sans-latin-ext-500-normal-BJfUCQsA.woff2 +0 -0
  160. package/dist/web/assets/dm-sans-latin-ext-500-normal-DR84L5F-.woff +0 -0
  161. package/dist/web/assets/dm-sans-latin-ext-600-normal-4vooXBpG.woff2 +0 -0
  162. package/dist/web/assets/dm-sans-latin-ext-600-normal-DRtaDpgU.woff +0 -0
  163. package/dist/web/assets/frame-DBWtBguh.js +0 -13
  164. package/dist/web/assets/index-ByIauY65.css +0 -2
  165. package/dist/web/assets/index-Tsofflw2.js +0 -57
  166. package/dist/web/assets/input-DX7REka8.js +0 -1
  167. package/dist/web/assets/markdown-Cj6qWQq7.js +0 -8
  168. package/dist/web/assets/pageBack-DmmT2q53.js +0 -3
  169. package/dist/web/assets/palette-CtM-T-2Q.js +0 -1
  170. package/dist/web/assets/paletteCommands-BYTeXpSW.js +0 -1
  171. package/dist/web/assets/parts-BQWLwMBf.js +0 -1
  172. package/dist/web/assets/productParts-2Ar8qxlW.js +0 -1
  173. package/dist/web/assets/qualityParts-_Sify8OE.js +0 -1
  174. package/dist/web/assets/recordTest-CL1Z2YWn.js +0 -1
  175. package/dist/web/assets/route-D8G-pTdk.js +0 -1
  176. package/dist/web/assets/stepper-p4Pkqn9_.js +0 -1
@@ -25,6 +25,7 @@ from typing import Any, Dict, Iterable, Iterator, List, Optional, Set, Tuple
25
25
  from urllib.parse import urlparse
26
26
 
27
27
  from . import flowmatch
28
+ from .d365 import SITE as D365_SITE, generated as d365_generated, generated_path as d365_generated_path, locators as d365_locators
28
29
  from .logins import secret_ref, text_envs
29
30
 
30
31
  VERSION = 1
@@ -378,12 +379,17 @@ def candidate_locators(f: Dict[str, Any]) -> List[Dict[str, Any]]:
378
379
  a: Dict[str, str] = f.get("attributes") or {}
379
380
  tag = f.get("tag") or "*"
380
381
  role, name = f.get("role") or "", f.get("name") or ""
382
+ # A Dynamics 365 page (d365.py): its own attributes first, as the dynamics-365 skill names its controls, and the ids
383
+ # it renders from where a control sits (AppModuleTileSec_1_Item_1) read down as generated.
384
+ d365 = f.get("site") == D365_SITE
385
+ if d365:
386
+ out.extend(d365_locators(f))
381
387
 
382
388
  def add(kind: str, value: str, playwright: str, **extra: Any) -> None:
383
389
  if not value:
384
390
  return
385
391
  base = BASE[kind]
386
- generated = kind in ("test_id", "id", "name", "href", "css") and looks_generated(value)
392
+ generated = kind in ("test_id", "id", "name", "href", "css") and (looks_generated(value) or (d365 and kind in ("id", "name", "css") and d365_generated(value)))
387
393
  if generated:
388
394
  base *= GENERATED_FACTOR
389
395
  loc = {"type": kind, "value": value, "playwright": playwright, "base": round(base, 3), **extra}
@@ -448,13 +454,13 @@ def candidate_locators(f: Dict[str, Any]) -> List[Dict[str, Any]]:
448
454
  if classes:
449
455
  css = tag + "".join(class_selector(c) for c in classes[:2])
450
456
  add("css", css, f"page.locator({_q(css)})", css=css)
451
- if f.get("scope"):
457
+ if f.get("scope") and not (d365 and d365_generated(str(f["scope"]))):
452
458
  # Within the item it belongs to: one of a control that repeats on every row or card.
453
459
  own = tag + "".join(class_selector(c) for c in classes[:2]) if classes else (f"{tag}[href={_q(href)}]" if tag == "a" and href else tag)
454
460
  css = f"{f['scope']} {own}"
455
461
  add("css", css, f"page.locator({_q(css)})", css=css, scoped=True)
456
462
  rel = str(f.get("rel_xpath") or "")
457
- if rel.startswith("//") and len(rel) <= MAX_REL_XPATH:
463
+ if rel.startswith("//") and len(rel) <= MAX_REL_XPATH and not (d365 and d365_generated_path(rel)):
458
464
  add("xpath_relative", rel, f"page.locator({_q('xpath=' + rel)})")
459
465
  if f.get("xpath"):
460
466
  xp = "/" + str(f["xpath"]).lstrip("/")
@@ -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 (facts.get("attributes") or {}).items() if k in KEPT_ATTRS and v},
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}
@@ -125,6 +126,9 @@ def to_flow(workflow: Mapping[str, Any], app_id: str, variables: Optional[Mappin
125
126
  cmds.append({"tapOn": {**_selector(d), "optional": True}})
126
127
  elif op == "close":
127
128
  cmds.append("stopApp")
129
+ elif op in ("tap", "double_tap") and (step.get("choice") or {}).get("how") == "any":
130
+ # Maestro runs a whole flow it was given: it cannot look through the controls for the first free one.
131
+ raise WorkflowError(f"step {i}: choosing any free control has no Maestro form; replay this workflow with Appium")
128
132
  elif op == "open_link":
129
133
  # Maestro's openLink takes the link as written, and a magic link is read when the step runs.
130
134
  raise WorkflowError(f"step {i}: a magic link read from the mailbox has no Maestro form; replay this workflow with Appium")