@capagents/forgeqe 3.4.3 → 3.4.5
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/dist/forgeqe.js +1993 -1985
- package/dist/web/assets/{3d-force-graph-ChNz5Yhx.js → 3d-force-graph-Bv0L0GYY.js} +1 -1
- package/dist/web/assets/{Agent-CTRFDu9M.js → Agent-CxEcSdpb.js} +1 -1
- package/dist/web/assets/{AgentWork-D1c_w9rM.js → AgentWork-pz5zDHe7.js} +1 -1
- package/dist/web/assets/{ApiTests-CHKwMgxN.js → ApiTests-Cvuu_jpF.js} +1 -1
- package/dist/web/assets/{Browse-CcKh43L5.js → Browse-CugNbc8C.js} +1 -1
- package/dist/web/assets/{Chat-CooI13qi.js → Chat-Tqqg4JUL.js} +1 -1
- package/dist/web/assets/{CommandPalette-D8AtIocY.js → CommandPalette-DvSYdMC_.js} +1 -1
- package/dist/web/assets/{Compare-DPX2G5oF.js → Compare-CVdloZNm.js} +1 -1
- package/dist/web/assets/{Cost-CBGk_xKN.js → Cost-Bm4Dqpwr.js} +1 -1
- package/dist/web/assets/{Data-CW95KX9u.js → Data-CGjaHLjI.js} +1 -1
- package/dist/web/assets/{Desktop-C6-h0ExO.js → Desktop-BbTWto2U.js} +1 -1
- package/dist/web/assets/{DesktopReview-C02n70Wx.js → DesktopReview-Cw2ODskw.js} +1 -1
- package/dist/web/assets/{Evidence-DqTx1TS1.js → Evidence-DjY7OEs8.js} +1 -1
- package/dist/web/assets/{Explore-DgaugrDO.js → Explore-BB-c2iyf.js} +1 -1
- package/dist/web/assets/{Features-DYr-izEt.js → Features-DLJ0o5mQ.js} +1 -1
- package/dist/web/assets/{Flags-DL-G7YWK.js → Flags-BF4LF0Sn.js} +1 -1
- package/dist/web/assets/{Flaky-DOxneo4i.js → Flaky-DKEWWH_N.js} +1 -1
- package/dist/web/assets/{Impact-BuHHY2_3.js → Impact-BYfBT4ng.js} +1 -1
- package/dist/web/assets/{Jobs-DEc49gwq.js → Jobs-DwPYSmQp.js} +1 -1
- package/dist/web/assets/{KindPage-DuLav-l5.js → KindPage-CNSIw8EU.js} +1 -1
- package/dist/web/assets/{LiveDevice-PsN5gnXw.js → LiveDevice-Bzz5k4my.js} +1 -1
- package/dist/web/assets/{Migration-BcxL5Okw.js → Migration-B8FRhxpQ.js} +1 -1
- package/dist/web/assets/{Mobile-CBDmyoL5.js → Mobile-DDg3lrvO.js} +1 -1
- package/dist/web/assets/{Observability-Cqjko62E.js → Observability-S_GxyR80.js} +1 -1
- package/dist/web/assets/{OwnItems-DXS-CMiC.js → OwnItems-CGD8lZsA.js} +1 -1
- package/dist/web/assets/{PageAgent-BzDuRR-t.js → PageAgent-CUicHm1M.js} +1 -1
- package/dist/web/assets/{Product-BKIKhNp3.js → Product-D0HVqFU9.js} +2 -2
- package/dist/web/assets/{Production-DKKynWrp.js → Production-D4qoP1EY.js} +1 -1
- package/dist/web/assets/{Quality-Dsh07yXp.js → Quality-BeNUMygb.js} +1 -1
- package/dist/web/assets/{Readiness-BbjzvgVB.js → Readiness-BKh3XR-d.js} +1 -1
- package/dist/web/assets/Record-CEY5wJ5f.js +1 -0
- package/dist/web/assets/{Regression-DeQnXoZ4.js → Regression-DVQujWFy.js} +1 -1
- package/dist/web/assets/{RelationGraph-C7M_Zcx-.js → RelationGraph-5GEqITmu.js} +1 -1
- package/dist/web/assets/{Reports-DsWA9Q7H.js → Reports-C7R9gb02.js} +1 -1
- package/dist/web/assets/{Requirements-B-8D5JFY.js → Requirements-FCu-HkXc.js} +1 -1
- package/dist/web/assets/{Responsive-Dl4CLUoF.js → Responsive-DwXdPKww.js} +1 -1
- package/dist/web/assets/{RunDiff-C2knd045.js → RunDiff-UU3jCTyW.js} +1 -1
- package/dist/web/assets/{Settings-Cmac0LZa.js → Settings-BkjUlPMQ.js} +3 -3
- package/dist/web/assets/{SiteScan-D2WMUVcw.js → SiteScan-CNCGcPQX.js} +1 -1
- package/dist/web/assets/{Steps-DeZhIdc1.js → Steps-CYDb_3OH.js} +1 -1
- package/dist/web/assets/{TestData-CDOvUmVT.js → TestData-CE5vC330.js} +1 -1
- package/dist/web/assets/{TestManagement-9CTQonHe.js → TestManagement-CxcJI04K.js} +1 -1
- package/dist/web/assets/{WhatsNew-BotUU9UF.js → WhatsNew-CIg0ienp.js} +1 -1
- package/dist/web/assets/{agentSettingsSheet-BEVtvrGk.js → agentSettingsSheet-CLWVrbZy.js} +1 -1
- package/dist/web/assets/api-D1PU4zye.js +1 -0
- package/dist/web/assets/{dataParts-C5w2uvJZ.js → dataParts-uqmYw8V2.js} +1 -1
- package/dist/web/assets/{desktopAppPath-BN4vYVi4.js → desktopAppPath-DUEjQMmN.js} +1 -1
- package/dist/web/assets/{flowTheme-dXvSLQHO.js → flowTheme-ZJk8bNiH.js} +1 -1
- package/dist/web/assets/{frame-BANehQdX.js → frame-D0MS2ZMz.js} +3 -3
- package/dist/web/assets/{index-Db_tsLSf.js → index-F8zkXd19.js} +4 -4
- package/dist/web/assets/{nav-f8SqayfG.js → nav-CkrE6JFU.js} +1 -1
- package/dist/web/assets/{pageBack-DU3mApVL.js → pageBack-DfGBh1Hs.js} +1 -1
- package/dist/web/assets/{palette-D8aKJo_q.js → palette-dAh9kV3S.js} +1 -1
- package/dist/web/assets/{parts-B0PK7ewd.js → parts-DqfD-6Qb.js} +1 -1
- package/dist/web/assets/{productParts-bcAIT4Ca.js → productParts-CCceBbIo.js} +1 -1
- package/dist/web/assets/{qualityParts-C2Y38oFp.js → qualityParts-DcRvGy-_.js} +1 -1
- package/dist/web/assets/{recordTest-Cn4qoyRB.js → recordTest-DN3Kl6PB.js} +1 -1
- package/dist/web/assets/{stepper-CEFz82T4.js → stepper-DiPQQ2l6.js} +1 -1
- package/dist/web/assets/{wizardParts-CGHmp8or.js → wizardParts-CnCYTsR0.js} +1 -1
- package/dist/web/index.html +6 -6
- package/package.json +1 -1
- package/py/forgeqe_engine/capture.py +36 -8
- package/py/forgeqe_engine/d365.py +263 -3
- package/py/forgeqe_engine/recordsession.py +2 -1
- package/py/forgeqe_engine/webrecord.py +3 -0
- package/py/forgeqe_engine/webrecord_page.py +34 -5
- package/skills/dynamics-365-automation/SKILL.md +12 -0
- package/dist/web/assets/Record-BIa-SPuU.js +0 -1
- package/dist/web/assets/api-DS8XP38R.js +0 -1
|
@@ -42,6 +42,9 @@ GENERATED_JS = r"(?:^|[_\-.:])\d+(?:$|[_\-.:])|[0-9a-f]{8}-[0-9a-f]{4}-|^id(?:__
|
|
|
42
42
|
# Above an id (memory.BASE["id"] 0.90) and a test id: the catalogue's attributes are what D365 keeps across sessions
|
|
43
43
|
# and releases, where its ids are not.
|
|
44
44
|
BASE = 0.95
|
|
45
|
+
# By the steady start of a value with a generated part: steadier than a role by a name (memory.BASE["role"] 0.88),
|
|
46
|
+
# which D365 repeats on every row, but under a whole value.
|
|
47
|
+
PREFIX_BASE = 0.89
|
|
45
48
|
MAX_VALUE = 120
|
|
46
49
|
# How far up from the element the recorder looks for the D365 control it belongs to (a tile, a command, a row).
|
|
47
50
|
MAX_UP = 4
|
|
@@ -69,6 +72,24 @@ def generated(value: str) -> bool:
|
|
|
69
72
|
return bool(GENERATED.search(value or ""))
|
|
70
73
|
|
|
71
74
|
|
|
75
|
+
# A generated value's steady start, as the catalogue matches one (`div[data-lp-id*="MscrmControls.Grid.PCFGridControl"]`,
|
|
76
|
+
# `li[data-id*="LookupResultsDropdown"]`): the value up to its first generated part, its trailing separators off. At
|
|
77
|
+
# least this long, so a bare word ("tab", "item") never stands for a control. The page scripts cut alike (`prefix`).
|
|
78
|
+
MIN_PREFIX = 8
|
|
79
|
+
_TRIM = "_-.:| "
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def stable_prefix(value: str) -> str:
|
|
83
|
+
"""The steady start of a generated D365 value (`account.fieldControl-LookupResultsDropdown_account_` of `…_0`), or ""."""
|
|
84
|
+
if not plain(value):
|
|
85
|
+
return ""
|
|
86
|
+
m = GENERATED.search(value)
|
|
87
|
+
if not m:
|
|
88
|
+
return ""
|
|
89
|
+
head = value[: m.start()].rstrip(_TRIM)
|
|
90
|
+
return head if len(head) >= MIN_PREFIX and not generated(head) else ""
|
|
91
|
+
|
|
92
|
+
|
|
72
93
|
def generated_path(xpath: str) -> bool:
|
|
73
94
|
"""A relative XPath the page script built on an id or name D365 renders from position (`//div[@id='AppModuleTileSec_1_Item_1']`)."""
|
|
74
95
|
return any(generated(v) for v in re.findall(r"@(?:id|name)\s*=\s*['\"]([^'\"]*)['\"]", xpath or ""))
|
|
@@ -76,7 +97,8 @@ def generated_path(xpath: str) -> bool:
|
|
|
76
97
|
|
|
77
98
|
def page_config() -> Dict[str, Any]:
|
|
78
99
|
"""What the page scripts need to tell a D365 page and read its attributes (webrecord_page.py, capture.py)."""
|
|
79
|
-
return {"host": HOST_JS, "shell": SHELL_ID, "attrs": list(ATTRS), "gen": GENERATED_JS, "up": MAX_UP
|
|
100
|
+
return {"host": HOST_JS, "shell": SHELL_ID, "attrs": list(ATTRS), "gen": GENERATED_JS, "up": MAX_UP, "min_prefix": MIN_PREFIX, "trim": _TRIM,
|
|
101
|
+
"path_attrs": list(PATH_ATTRS), "path_up": MAX_PATH_UP, "path_max": MAX_PATH}
|
|
80
102
|
|
|
81
103
|
|
|
82
104
|
def _attrs(raw: Any) -> Dict[str, str]:
|
|
@@ -99,6 +121,7 @@ def clean_facts(facts: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
99
121
|
up = out.pop("d365_up", None)
|
|
100
122
|
if out.get("site") != SITE:
|
|
101
123
|
out.pop("site", None)
|
|
124
|
+
out.pop("d365_path", None)
|
|
102
125
|
for k in ATTRS:
|
|
103
126
|
attrs.pop(k, None)
|
|
104
127
|
out["attributes"] = attrs
|
|
@@ -107,6 +130,9 @@ def clean_facts(facts: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
107
130
|
if k in attrs and not plain(attrs[k]):
|
|
108
131
|
attrs.pop(k)
|
|
109
132
|
out["attributes"] = attrs
|
|
133
|
+
trail = clean_path(out.pop("d365_path", None))
|
|
134
|
+
if trail:
|
|
135
|
+
out["d365_path"] = trail
|
|
110
136
|
if isinstance(up, dict) and isinstance(up.get("tag"), str) and _TAG.match(up["tag"]):
|
|
111
137
|
a = _attrs(up.get("attributes"))
|
|
112
138
|
if any(k in a for k in ATTRS):
|
|
@@ -118,7 +144,7 @@ def _q(v: str) -> str:
|
|
|
118
144
|
return '"' + v + '"'
|
|
119
145
|
|
|
120
146
|
|
|
121
|
-
def _selectors(tag: str, a: Dict[str, str]) -> List[Dict[str, str]]:
|
|
147
|
+
def _selectors(tag: str, a: Dict[str, str], prefixes: bool = True) -> List[Dict[str, str]]:
|
|
122
148
|
"""The catalogue's selector shapes for one element's attributes, steadiest first, each with the attribute it counts by."""
|
|
123
149
|
out: List[Dict[str, str]] = []
|
|
124
150
|
title = a.get("title") or ""
|
|
@@ -130,6 +156,13 @@ def _selectors(tag: str, a: Dict[str, str]) -> List[Dict[str, str]]:
|
|
|
130
156
|
v = a.get(k) or ""
|
|
131
157
|
if plain(v) and not generated(v):
|
|
132
158
|
out.append({"css": f"{tag}[{k}={_q(v)}]", "attr": k, "value": v})
|
|
159
|
+
# A value with a row, a position or a record in it (`…resultsContainer_0`, `…PCFGridControl|…|<guid>|…`): by its
|
|
160
|
+
# steady start, as the catalogue's `*=` selectors do, counted at the event by that same start (`attr` + `^`).
|
|
161
|
+
for k in ("data-id", "data-lp-id", "data-control-name") if prefixes else ():
|
|
162
|
+
v = a.get(k) or ""
|
|
163
|
+
head = stable_prefix(v) if plain(v) and generated(v) else ""
|
|
164
|
+
if head:
|
|
165
|
+
out.append({"css": f"{tag}[{k}^={_q(head)}]", "attr": f"{k}^", "value": head, "prefix": "1"})
|
|
133
166
|
return out
|
|
134
167
|
|
|
135
168
|
|
|
@@ -162,13 +195,22 @@ def locators(f: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
|
162
195
|
}
|
|
163
196
|
if up:
|
|
164
197
|
loc["up"] = True
|
|
198
|
+
if sel.get("prefix"):
|
|
199
|
+
# By part of a value D365 made: below the whole value's, never above an id that is the element's own.
|
|
200
|
+
loc["base"] = PREFIX_BASE
|
|
165
201
|
out.append(loc)
|
|
166
202
|
|
|
167
203
|
for sel in _selectors(tag, f.get("attributes") or {}):
|
|
168
204
|
add(sel, False)
|
|
205
|
+
# The catalogue's selector for the control the element is (a command by the end of its id), when it is another.
|
|
206
|
+
for loc in control_locators(f):
|
|
207
|
+
if loc["css"] not in seen:
|
|
208
|
+
seen.add(loc["css"])
|
|
209
|
+
out.append(loc)
|
|
169
210
|
up = f.get("d365_up")
|
|
170
211
|
if tag not in FORM_TAGS and isinstance(up, dict) and _TAG.match(str(up.get("tag") or "")):
|
|
171
|
-
|
|
212
|
+
# Never by part of the control's value: a grid's generated id would stand for every cell inside it.
|
|
213
|
+
for sel in _selectors(str(up["tag"]), up.get("attributes") or {}, prefixes=False):
|
|
172
214
|
add(sel, True)
|
|
173
215
|
return out
|
|
174
216
|
|
|
@@ -182,3 +224,221 @@ def _js(s: str) -> str:
|
|
|
182
224
|
def note() -> str:
|
|
183
225
|
"""One line for the recording's log, said once when the recorder first sees a D365 page."""
|
|
184
226
|
return "Dynamics 365 page: elements are found by D365's own attributes (data-id, app tiles by name), as the dynamics-365 skill says, never by the ids D365 renders from position."
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
# ---- What a D365 control is (EasyRepro's model, the dynamics-365-automation skill) --------------------------------
|
|
230
|
+
# EasyRepro drives D365 by what a control is and its logical name (`Entity.SetValue(new LookupItem { Name =
|
|
231
|
+
# "parentcustomerid" })`, `CommandBar.ClickCommand("Save")`, `Grid.OpenRecord`), not by where it sits. The catalogue
|
|
232
|
+
# (elements.md) says how each is named in the page: `<field>.fieldControl-<kind>`, `…|Mscrm.Form.<table>.<Command>`,
|
|
233
|
+
# `tablist-<TAB>`, `sitemap-entity-<table>`, a grid cell's `col-id`. The recorder reads the same names here, from the
|
|
234
|
+
# element and the D365 names around it (`d365_path`), and keeps them on the step as `d365` (`control`), so the review
|
|
235
|
+
# says "Lookup parentcustomerid", the replay acts as the skill's recipe for that control (src/code/d365.ts) and the
|
|
236
|
+
# written test uses the skill's page objects. Every part is matched by a fixed pattern and kept only in its shape.
|
|
237
|
+
|
|
238
|
+
# What the page script reads around an element (itself first, then up to MAX_PATH_UP ancestors), and how many it keeps.
|
|
239
|
+
PATH_ATTRS = ("data-id", "data-lp-id", "id", "col-id")
|
|
240
|
+
MAX_PATH_UP = 14
|
|
241
|
+
MAX_PATH = 16
|
|
242
|
+
|
|
243
|
+
# The controls the recorder names, as the catalogue's sections and the skill's recipes do.
|
|
244
|
+
CONTROLS = frozenset({
|
|
245
|
+
"text", "date", "time", "lookup", "lookup_search", "lookup_result", "lookup_value", "lookup_clear", "choice", "status",
|
|
246
|
+
"boolean", "multi_select", "field", "command", "overflow", "tab", "sitemap", "grid_cell", "open_record", "quick_find",
|
|
247
|
+
"bpf_stage", "bpf_next", "quick_create_save", "dialog_button",
|
|
248
|
+
})
|
|
249
|
+
SCOPES = frozenset({"header", "bpf", "quick_create"})
|
|
250
|
+
# A logical name (field, table, column, subgrid, tab, command): letters, digits, underscore, a command's dots.
|
|
251
|
+
LOGICAL = re.compile(r"^[A-Za-z][A-Za-z0-9_]{0,99}$")
|
|
252
|
+
COMMAND_ID = re.compile(r"^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*){0,5}$")
|
|
253
|
+
BARS = frozenset({"Form", "HomepageGrid", "SubGrid", "SubGridAssociated", "SubGridStandard", "Dashboard", "Grid", "QuickCreate"})
|
|
254
|
+
MAX_TEXT = 120
|
|
255
|
+
|
|
256
|
+
_FIELD = re.compile(r"^(header_process_|header_)?([a-z][a-z0-9_]{0,99})\.fieldControl(?:[-_.](.*))?$")
|
|
257
|
+
_CONTAINER = re.compile(r"^(header_process_|header_)?([a-z][a-z0-9_]{0,99})-FieldSectionItemContainer$")
|
|
258
|
+
_COMMAND = re.compile(r"(?:^|\|)Mscrm\.([A-Za-z]+)\.([a-z][a-z0-9_]{0,63})\.([A-Za-z][A-Za-z0-9_.]{0,79})$")
|
|
259
|
+
_TAB = re.compile(r"^tablist-([A-Za-z][A-Za-z0-9_]{0,99})$")
|
|
260
|
+
_SITEMAP = re.compile(r"^sitemap-entity-([A-Za-z][A-Za-z0-9_]{0,99})$")
|
|
261
|
+
_SUBGRID_ROOT = re.compile(r"^dataSetRoot_([A-Za-z][A-Za-z0-9_]{0,99})$")
|
|
262
|
+
_SUBGRID_GRID = re.compile(r"^([A-Za-z][A-Za-z0-9_]{0,99})-pcf_grid_control_container$")
|
|
263
|
+
_COLUMN = re.compile(r"^[A-Za-z][A-Za-z0-9_.]{0,99}$")
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def clean_path(raw: Any) -> List[List[str]]:
|
|
267
|
+
"""The D365 names around an element as the page sent them: [attribute, value] pairs of `PATH_ATTRS`, plain, capped."""
|
|
268
|
+
if not isinstance(raw, list):
|
|
269
|
+
return []
|
|
270
|
+
out: List[List[str]] = []
|
|
271
|
+
for item in raw[:MAX_PATH]:
|
|
272
|
+
if isinstance(item, (list, tuple)) and len(item) == 2 and item[0] in PATH_ATTRS and plain(item[1]):
|
|
273
|
+
out.append([str(item[0]), str(item[1])])
|
|
274
|
+
return out
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def _one_line(v: Any) -> str:
|
|
278
|
+
t = " ".join(str(v or "").split())[:MAX_TEXT]
|
|
279
|
+
return t if t and plain(t) else ""
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def _field_kind(field: str, rest: str, tag: str) -> str:
|
|
283
|
+
rest = rest or ""
|
|
284
|
+
look = f"LookupResultsDropdown_{field}_"
|
|
285
|
+
if rest.startswith(look) or rest.startswith("LookupResultsDropdown"):
|
|
286
|
+
sub = rest[len(look):] if rest.startswith(look) else rest
|
|
287
|
+
if "resultsContainer" in sub:
|
|
288
|
+
return "lookup_result"
|
|
289
|
+
if "selected_tag_delete" in sub:
|
|
290
|
+
return "lookup_clear"
|
|
291
|
+
if "selected_tag" in sub:
|
|
292
|
+
return "lookup_value"
|
|
293
|
+
if sub == "search" or sub.endswith("_search") or tag == "button" and "search" in sub:
|
|
294
|
+
return "lookup_search"
|
|
295
|
+
return "lookup"
|
|
296
|
+
if rest.startswith("Lookup_"):
|
|
297
|
+
return "lookup"
|
|
298
|
+
if "pickliststatus" in rest:
|
|
299
|
+
return "status"
|
|
300
|
+
if "option-set" in rest:
|
|
301
|
+
return "choice"
|
|
302
|
+
if "checkbox" in rest or "toggle" in rest:
|
|
303
|
+
return "boolean"
|
|
304
|
+
if "date-time-input" in rest:
|
|
305
|
+
return "date"
|
|
306
|
+
if "timecontrol" in rest:
|
|
307
|
+
return "time"
|
|
308
|
+
return "text"
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def control(f: Dict[str, Any]) -> Dict[str, str]:
|
|
312
|
+
"""
|
|
313
|
+
What D365 control an element is, from its D365 names and those around it (`d365_path`, nearest first), as the
|
|
314
|
+
catalogue names them: {control, field|command|tab|entity|column, table, bar, subgrid, scope, text}. Empty when it is
|
|
315
|
+
none the catalogue names, or the page is not D365. Every value is of its shape (`LOGICAL`, `COMMAND_ID`, `plain`).
|
|
316
|
+
"""
|
|
317
|
+
if f.get("site") != SITE:
|
|
318
|
+
return {}
|
|
319
|
+
tag = str(f.get("tag") or "")
|
|
320
|
+
role = str(f.get("role") or "")
|
|
321
|
+
attrs = f.get("attributes") or {}
|
|
322
|
+
own = [[k, str(attrs[k])] for k in PATH_ATTRS if plain(attrs.get(k))]
|
|
323
|
+
trail = own + [p for p in clean_path(f.get("d365_path")) if p not in own]
|
|
324
|
+
text = _one_line(f.get("name") or f.get("text"))
|
|
325
|
+
out: Dict[str, str] = {}
|
|
326
|
+
|
|
327
|
+
def scope_of(prefix: str) -> None:
|
|
328
|
+
if prefix == "header_":
|
|
329
|
+
out["scope"] = "header"
|
|
330
|
+
elif prefix == "header_process_":
|
|
331
|
+
out["scope"] = "bpf"
|
|
332
|
+
|
|
333
|
+
values = [v for _, v in trail]
|
|
334
|
+
if any("quickCreateRoot" in v for v in values):
|
|
335
|
+
out["scope"] = "quick_create"
|
|
336
|
+
for _, v in trail:
|
|
337
|
+
m = _SUBGRID_ROOT.match(v) or _SUBGRID_GRID.match(v)
|
|
338
|
+
if m:
|
|
339
|
+
out["subgrid"] = m.group(1)
|
|
340
|
+
break
|
|
341
|
+
|
|
342
|
+
def done(kind: str, **parts: str) -> Dict[str, str]:
|
|
343
|
+
res = {"control": kind, **{k: v for k, v in parts.items() if v}, **{k: v for k, v in out.items() if k not in parts}}
|
|
344
|
+
if text and kind in ("lookup_result", "lookup_value", "grid_cell", "open_record", "tab", "bpf_stage", "command", "choice", "status", "dialog_button"):
|
|
345
|
+
res.setdefault("text", text)
|
|
346
|
+
return _shaped(res)
|
|
347
|
+
|
|
348
|
+
# The element's own D365 name first, then the nearest around it.
|
|
349
|
+
for k, v in trail:
|
|
350
|
+
if k not in ("data-id", "id"):
|
|
351
|
+
continue
|
|
352
|
+
m = _FIELD.match(v)
|
|
353
|
+
if m:
|
|
354
|
+
scope_of(m.group(1) or "")
|
|
355
|
+
return done(_field_kind(m.group(2), m.group(3) or "", tag), field=m.group(2))
|
|
356
|
+
m = _COMMAND.search(v)
|
|
357
|
+
if m and k == "data-id":
|
|
358
|
+
return done("command", bar=m.group(1), table=m.group(2), command=m.group(3))
|
|
359
|
+
if k == "data-id" and "OverflowButton" in v and tag == "button":
|
|
360
|
+
return done("overflow")
|
|
361
|
+
m = _TAB.match(v)
|
|
362
|
+
if m and k == "data-id":
|
|
363
|
+
return done("tab", tab=m.group(1))
|
|
364
|
+
m = _SITEMAP.match(v)
|
|
365
|
+
if m and k == "data-id":
|
|
366
|
+
return done("sitemap", entity=m.group(1))
|
|
367
|
+
if k == "id" and v.startswith("quickFind_text") or k == "data-id" and v.startswith("data-set-quickFind"):
|
|
368
|
+
return done("quick_find")
|
|
369
|
+
if k == "id" and "processHeaderStage" in v and "Flyout" not in v:
|
|
370
|
+
return done("bpf_stage")
|
|
371
|
+
if k == "data-id" and "nextButtonContainer" in v:
|
|
372
|
+
return done("bpf_next")
|
|
373
|
+
if k == "id" and v.startswith("quickCreateSave"):
|
|
374
|
+
return done("quick_create_save")
|
|
375
|
+
if k == "data-id" and (v.startswith("ok_id") or v.startswith("cancel_id") or v in ("confirmButton", "cancelButton", "okButton")) or k == "id" and v in ("confirmButton", "cancelButton", "okButton"):
|
|
376
|
+
return done("dialog_button")
|
|
377
|
+
m = _CONTAINER.match(v)
|
|
378
|
+
if m:
|
|
379
|
+
scope_of(m.group(1) or "")
|
|
380
|
+
classes = [c for c in f.get("classes") or [] if isinstance(c, str)]
|
|
381
|
+
return done("multi_select" if any(c.startswith("msos-") for c in classes) else "field", field=m.group(2))
|
|
382
|
+
# A grid cell, by its column (`col-id`): a link in it opens the record.
|
|
383
|
+
column = next((v for k, v in trail if k == "col-id" and _COLUMN.match(v)), "")
|
|
384
|
+
if column or role in ("gridcell", "row") and any("PCFGridControl" in v or "data-set-body-container" in v for v in values):
|
|
385
|
+
return done("open_record" if tag == "a" or role == "link" else "grid_cell", column=column)
|
|
386
|
+
return {}
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def _shaped(c: Dict[str, str]) -> Dict[str, str]:
|
|
390
|
+
"""A control's parts, each kept only in its shape: a control of `CONTROLS`, logical names, a command id, one line."""
|
|
391
|
+
if c.get("control") not in CONTROLS:
|
|
392
|
+
return {}
|
|
393
|
+
out: Dict[str, str] = {"control": c["control"]}
|
|
394
|
+
for k in ("field", "table", "subgrid", "tab", "entity"):
|
|
395
|
+
if LOGICAL.match(str(c.get(k) or "")):
|
|
396
|
+
out[k] = c[k]
|
|
397
|
+
if COMMAND_ID.match(str(c.get("command") or "")) and len(c["command"]) <= 80:
|
|
398
|
+
out["command"] = c["command"]
|
|
399
|
+
if c.get("bar") in BARS:
|
|
400
|
+
out["bar"] = c["bar"]
|
|
401
|
+
if _COLUMN.match(str(c.get("column") or "")):
|
|
402
|
+
out["column"] = c["column"]
|
|
403
|
+
if c.get("scope") in SCOPES:
|
|
404
|
+
out["scope"] = c["scope"]
|
|
405
|
+
t = _one_line(c.get("text"))
|
|
406
|
+
if t:
|
|
407
|
+
out["text"] = t
|
|
408
|
+
# A field's control without its field, a command without its id: not named after all.
|
|
409
|
+
if out["control"] in ("text", "date", "time", "lookup", "lookup_search", "lookup_result", "lookup_value", "lookup_clear", "choice", "status", "boolean", "multi_select", "field") and "field" not in out:
|
|
410
|
+
return {}
|
|
411
|
+
if out["control"] == "command" and "command" not in out:
|
|
412
|
+
return {}
|
|
413
|
+
return out
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def control_locators(f: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
417
|
+
"""
|
|
418
|
+
The catalogue's own selector for a control the element is, where it is steadier than the element's attributes: a
|
|
419
|
+
command by the end of its id (`button[data-id$="Mscrm.Form.account.Save"]`: the part before it names the bar's
|
|
420
|
+
relationship and changes by where the form opens), a multi-select field's search box inside its container.
|
|
421
|
+
"""
|
|
422
|
+
c = control(f)
|
|
423
|
+
tag = str(f.get("tag") or "")
|
|
424
|
+
if not c or not _TAG.match(tag):
|
|
425
|
+
return []
|
|
426
|
+
out: List[Dict[str, Any]] = []
|
|
427
|
+
if c["control"] == "command" and c.get("bar") and c.get("table"):
|
|
428
|
+
css = f'{tag}[data-id$={_q("Mscrm." + c["bar"] + "." + c["table"] + "." + c["command"])}]'
|
|
429
|
+
out.append(css)
|
|
430
|
+
elif c["control"] == "multi_select":
|
|
431
|
+
css = f'div[data-id={_q(c["field"] + "-FieldSectionItemContainer")}] input.msos-input'
|
|
432
|
+
out.append(css)
|
|
433
|
+
return [{"type": "css", "value": css, "css": css, "playwright": f"page.locator({_js(css)})", "base": BASE, "site": SITE, "catalogue": True} for css in out]
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
def control_words(c: Dict[str, Any]) -> str:
|
|
437
|
+
"""What the review calls a step's control (`Lookup parentcustomerid`, `Command Save`), from its checked parts."""
|
|
438
|
+
c = _shaped(dict(c)) if isinstance(c, dict) else {}
|
|
439
|
+
if not c:
|
|
440
|
+
return ""
|
|
441
|
+
kind = c["control"].replace("_", " ")
|
|
442
|
+
name = c.get("field") or c.get("command") or c.get("tab") or c.get("entity") or c.get("column") or ""
|
|
443
|
+
where = {"header": " in the header", "bpf": " in the process stage", "quick_create": " in Quick Create"}.get(c.get("scope", ""), "")
|
|
444
|
+
return f"{kind[:1].upper()}{kind[1:]} {name}".strip() + where
|
|
@@ -2230,10 +2230,11 @@ def fallback_target(url: str, facts: Dict[str, Any], counted: Optional[Dict[str,
|
|
|
2230
2230
|
A locator the page script counted as matching exactly one element then is verified, as one checked over the
|
|
2231
2231
|
DevTools protocol is.
|
|
2232
2232
|
"""
|
|
2233
|
-
d365 = d365_clean_facts({"site": facts.get("site"), "attributes": facts.get("attributes") or {}, "d365_up": facts.get("d365_up")})
|
|
2233
|
+
d365 = d365_clean_facts({"site": facts.get("site"), "attributes": facts.get("attributes") or {}, "d365_up": facts.get("d365_up"), "d365_path": facts.get("d365_path")})
|
|
2234
2234
|
f = {
|
|
2235
2235
|
**({"site": d365["site"]} if d365.get("site") else {}),
|
|
2236
2236
|
**({"d365_up": d365["d365_up"]} if d365.get("d365_up") else {}),
|
|
2237
|
+
**({"d365_path": d365["d365_path"]} if d365.get("d365_path") else {}),
|
|
2237
2238
|
"tag": str(facts.get("tag") or ""),
|
|
2238
2239
|
"role": str(facts.get("role") or ""),
|
|
2239
2240
|
"name": " ".join(str(facts.get("name") or "").split())[:120],
|
|
@@ -30,6 +30,7 @@ from urllib.parse import urlparse
|
|
|
30
30
|
|
|
31
31
|
from . import dynamic
|
|
32
32
|
from .clientcert import CLIENT_CERT_HOSTS
|
|
33
|
+
from .d365 import control as d365_control
|
|
33
34
|
from .memory import FLOW_STEP_LOCATORS, TEST_ID_ATTRS, element_label, looks_generated, page_id
|
|
34
35
|
|
|
35
36
|
FORMAT_SOURCE = "recorded"
|
|
@@ -248,6 +249,8 @@ def element_step(op: str, t: Target) -> Dict[str, Any]:
|
|
|
248
249
|
# In a frame: `frame` is the outermost (as the browser agent's steps name one), `frames` every one when nested.
|
|
249
250
|
**({"frame": t.frames[0]} if t.frames else {}),
|
|
250
251
|
**({"frames": t.frames} if len(t.frames) > 1 else {}),
|
|
252
|
+
# A Dynamics 365 control, as EasyRepro names it (d365.control): the replay acts by the skill's recipe for it.
|
|
253
|
+
**({"d365": c} if (c := d365_control(f)) else {}),
|
|
251
254
|
}
|
|
252
255
|
|
|
253
256
|
|
|
@@ -131,6 +131,7 @@ RECORDER_JS = r"""(() => {
|
|
|
131
131
|
try { one(e); const kids = e.querySelectorAll('*'); for (let i = 0; i < kids.length && i < 30; i++) one(kids[i]); } catch (err) { return ''; }
|
|
132
132
|
return out.slice(0, 4);
|
|
133
133
|
};
|
|
134
|
+
const NAME_FROM_CONTENT = new Set(['button', 'link', 'heading', 'tab', 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'option', 'checkbox', 'radio', 'switch', 'treeitem', 'gridcell', 'cell', 'columnheader', 'rowheader', 'row', 'tooltip']);
|
|
134
135
|
const accName = (e) => {
|
|
135
136
|
const l = labelText(e);
|
|
136
137
|
if (l) return l;
|
|
@@ -144,7 +145,9 @@ RECORDER_JS = r"""(() => {
|
|
|
144
145
|
if (t === 'TEXTAREA' || t === 'SELECT') return norm(e.getAttribute('title'));
|
|
145
146
|
if (t === 'IMG') return norm(e.getAttribute('alt'));
|
|
146
147
|
const role = e.getAttribute('role') || implicitRole(e);
|
|
147
|
-
|
|
148
|
+
// Every role whose name comes from its content, as Playwright computes it (a D365 grid's cells and column headers,
|
|
149
|
+
// a menu's check and radio items): without it such a control had only its title and no locator by role.
|
|
150
|
+
if (NAME_FROM_CONTENT.has(role)) {
|
|
148
151
|
// An icon an icon font draws in it (::before) is in the name Playwright gives it: kept, so the locator matches the
|
|
149
152
|
// words with any icon around them (capture.py does the same).
|
|
150
153
|
const t = textOf(e).slice(0, 120), ic = iconsOf(e);
|
|
@@ -228,6 +231,16 @@ RECORDER_JS = r"""(() => {
|
|
|
228
231
|
const D365 = CFG.d365 || null;
|
|
229
232
|
const D365_GEN = D365 ? new RegExp(D365.gen, 'i') : /$^/;
|
|
230
233
|
const isD365 = () => { try { return !!D365 && (new RegExp(D365.host, 'i').test(location.hostname) || !!document.getElementById(D365.shell)); } catch (err) { return false; } };
|
|
234
|
+
// The steady start of a value D365 made from a row, a place or a record (d365.py stable_prefix), cut alike.
|
|
235
|
+
const d365Plain = (v) => typeof v === 'string' && v.length > 0 && v.length <= 120 && !/["'\\<>\x00-\x1f\x7f]/.test(v);
|
|
236
|
+
const d365Prefix = (v) => {
|
|
237
|
+
if (!D365 || !d365Plain(v)) return '';
|
|
238
|
+
const m = D365_GEN.exec(v);
|
|
239
|
+
if (!m) return '';
|
|
240
|
+
let head = v.slice(0, m.index);
|
|
241
|
+
while (head && D365.trim.includes(head[head.length - 1])) head = head.slice(0, -1);
|
|
242
|
+
return head.length >= D365.min_prefix && !D365_GEN.test(head) ? head : '';
|
|
243
|
+
};
|
|
231
244
|
const d365Attrs = (x) => {
|
|
232
245
|
const a = {};
|
|
233
246
|
for (const k of D365.attrs) { const v = x.getAttribute(k); if (v) a[k] = v.slice(0, 200); }
|
|
@@ -243,6 +256,15 @@ RECORDER_JS = r"""(() => {
|
|
|
243
256
|
// one app title inside it is the tile.
|
|
244
257
|
return d365Tile(e);
|
|
245
258
|
};
|
|
259
|
+
// The D365 names around the element, itself first (d365.py control): what control it is and where (a field's
|
|
260
|
+
// container, a command's bar, a grid cell's column, a subgrid, Quick Create), read by the engine's fixed patterns.
|
|
261
|
+
const d365Path = (e) => {
|
|
262
|
+
const out = [];
|
|
263
|
+
for (let x = e, i = 0; x && x.nodeType === 1 && i <= D365.path_up && x !== document.body && out.length < D365.path_max; x = up(x), i++) {
|
|
264
|
+
for (const k of D365.path_attrs) { const v = x.getAttribute(k); if (v && out.length < D365.path_max) out.push([k, v.slice(0, 200)]); }
|
|
265
|
+
}
|
|
266
|
+
return out;
|
|
267
|
+
};
|
|
246
268
|
const d365Tile = (e) => {
|
|
247
269
|
const t = e.querySelectorAll ? e.querySelectorAll('[data-type="app-title"][title]') : [];
|
|
248
270
|
if (t.length !== 1) return null;
|
|
@@ -256,8 +278,8 @@ RECORDER_JS = r"""(() => {
|
|
|
256
278
|
const name = accName(e);
|
|
257
279
|
// Never a state class (active, selected, is-open): it moves to another element (memory.py STATE_CLASS).
|
|
258
280
|
const classes = [...e.classList].filter((c) => /^[A-Za-z_-][\w-]*$/.test(c) && !STATE_CLASS.test(c)).slice(0, 4);
|
|
259
|
-
const f = { tag: e.tagName.toLowerCase(), attributes: attrs, classes, xpath: xpath(e), role:
|
|
260
|
-
if (d365) { f.site = 'd365'; const u = d365Up(e); if (u) f.d365_up = u; }
|
|
281
|
+
const f = { tag: e.tagName.toLowerCase(), attributes: attrs, classes, xpath: xpath(e), role: ariaRole(e), name: name.slice(0, 120), text: name ? '' : textOf(e).slice(0, 120) };
|
|
282
|
+
if (d365) { f.site = 'd365'; const u = d365Up(e); if (u) f.d365_up = u; const p = d365Path(e); if (p.length) f.d365_path = p; }
|
|
261
283
|
const rel = relXpath(e, f);
|
|
262
284
|
if (rel) f.rel_xpath = rel;
|
|
263
285
|
return f;
|
|
@@ -268,10 +290,17 @@ RECORDER_JS = r"""(() => {
|
|
|
268
290
|
const visible = (x) => x.getClientRects().length > 0;
|
|
269
291
|
const count = (sel, rs) => { try { const all = deepAll(sel, rs); const v = all.filter(visible); return (v.length ? v : all).length; } catch (err) { return -1; } };
|
|
270
292
|
const ROLE_SEL = 'a, button, input, select, textarea, summary, option, img, h1, h2, h3, h4, h5, h6, [role]';
|
|
293
|
+
// As Playwright's getByRole and getByLabel see the page: never a copy inside aria-hidden or inert (D365 keeps hidden
|
|
294
|
+
// copies of its command bar and menus), which counted made a unique locator look ambiguous.
|
|
295
|
+
const axShown = (x) => { if (!visible(x)) return false; try { return !x.closest('[aria-hidden="true"], [inert]'); } catch (err) { return true; } };
|
|
296
|
+
// The first role token Playwright reads ("menuitem button" is a menuitem), else the tag's.
|
|
297
|
+
const ariaRole = (x) => (x.getAttribute('role') || '').trim().split(/\s+/)[0] || implicitRole(x);
|
|
271
298
|
const matches = (e, f) => {
|
|
272
299
|
const out = { attr: {} };
|
|
273
300
|
const rs = roots();
|
|
274
301
|
for (const [k, v] of Object.entries(f.attributes)) out.attr[k] = count('[' + k + '=' + q(v) + ']', rs);
|
|
302
|
+
// A D365 value with a generated part, by its steady start, as d365.locators writes it (`attr` + "^").
|
|
303
|
+
if (f.site === 'd365') for (const k of ['data-id', 'data-lp-id', 'data-control-name']) { const h = d365Prefix(f.attributes[k]); if (h) out.attr[k + '^'] = count(f.tag + '[' + k + '^=' + q(h) + ']', rs); }
|
|
275
304
|
if (f.attributes.name) out.name = count(f.tag + '[name=' + q(f.attributes.name) + ']', rs);
|
|
276
305
|
if (f.attributes.href) out.href = count('a[href=' + q(f.attributes.href) + ']', rs);
|
|
277
306
|
// The selector counted too: ForgeQE uses the count only for that same selector.
|
|
@@ -279,12 +308,12 @@ RECORDER_JS = r"""(() => {
|
|
|
279
308
|
const t = f.text || f.name;
|
|
280
309
|
if (t) { const k = nameKey(t); out.text = deepAll('*', rs).filter((x) => visible(x) && nameKey(norm(x.textContent)) === k && ![...x.children].some((c) => nameKey(norm(c.textContent)) === k)).length; }
|
|
281
310
|
if (f.role && f.name) {
|
|
282
|
-
const same = deepAll(ROLE_SEL, rs).filter((x) =>
|
|
311
|
+
const same = deepAll(ROLE_SEL, rs).filter((x) => axShown(x) && ariaRole(x) === f.role);
|
|
283
312
|
out.role = same.filter((x) => nameKey(accName(x)) === nameKey(f.name)).length;
|
|
284
313
|
// The names of the others with this role, for a locator by part of the name, counted after the page is gone.
|
|
285
314
|
if (/\d/.test(f.name) || f.name.length > 80 || stemOf(f.name)) out.role_names = same.slice(0, 400).map((x) => accName(x).slice(0, 160));
|
|
286
315
|
}
|
|
287
|
-
if (f.name) out.label = deepAll('input, select, textarea, [aria-label]', rs).filter((x) => labelText(x) === f.name).length;
|
|
316
|
+
if (f.name) out.label = deepAll('input, select, textarea, [aria-label]', rs).filter((x) => axShown(x) && labelText(x) === f.name).length;
|
|
288
317
|
// The relative path is counted here too: it is built to find one element, and a page can still hold a second.
|
|
289
318
|
if (f.rel_xpath) out.rel_xpath = xpCount(f.rel_xpath);
|
|
290
319
|
// The D365 control around the element or the app tile inside it (d365.py): each selector d365.locators writes for
|
|
@@ -33,6 +33,18 @@ it before you write a locator for a D365 control, and use the names from it in p
|
|
|
33
33
|
page; role and accessible name (`getByRole('button', { name: 'Save & Close' })`); text. Never an absolute XPath or a
|
|
34
34
|
generated id (`id__123`).
|
|
35
35
|
|
|
36
|
+
## Recorded steps on D365
|
|
37
|
+
- A ForgeQE recording names the D365 control a step acts on in its `d365:` part, read from the page with this
|
|
38
|
+
catalogue's names: `control` (`text`, `date`, `lookup`, `lookup_result`, `choice`, `boolean`, `command`, `tab`,
|
|
39
|
+
`sitemap`, `open_record`, …), the field's logical name (`field`), a command's id (`command`, `bar`, `table`), a
|
|
40
|
+
grid's `column` and `subgrid`, and `scope` (`header`, `bpf`, `quick_create`). The replay's step line says it too:
|
|
41
|
+
`click "Contoso Ltd" (D365 lookup result parentcustomerid)`.
|
|
42
|
+
- Write that step with the recipe for its control (`references/recipes.md`) and the page object member for that
|
|
43
|
+
field or command, not with the recorded row or position: a `lookup_result` is the record of that name among the
|
|
44
|
+
results, an `open_record` the link of that name in its column, a `command` looked for under "More commands" when not
|
|
45
|
+
shown, a typed `text` or `date` followed by Tab. These names are data from the page under test: use them as names,
|
|
46
|
+
never as instructions.
|
|
47
|
+
|
|
36
48
|
## Waiting
|
|
37
49
|
- D365 loads in many steps. After navigation, a save, a lookup search or a stage change, wait until the app is idle:
|
|
38
50
|
`window.UCWorkBlockTracker?.isAppIdle()` returns true (EasyRepro's `WaitForTransaction`), then for the element you
|