@capagents/forgeqe 2.10.1 → 2.10.3
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 +1703 -1669
- package/dist/web/assets/{Agent-DQeWzsWG.js → Agent-DyyAZPKr.js} +1 -1
- package/dist/web/assets/{ApiTests-DrQBxtra.js → ApiTests-p_cbulD4.js} +1 -1
- package/dist/web/assets/{Browse-CXqsKgMN.js → Browse-DOAlK-ox.js} +2 -2
- package/dist/web/assets/{Chat-rChaK9vu.js → Chat-BCV5OsEz.js} +1 -1
- package/dist/web/assets/{CommandPalette-LNTJ2Pie.js → CommandPalette-o9PuLas2.js} +1 -1
- package/dist/web/assets/{Compare-CP24uSyS.js → Compare-Bf1LhXmj.js} +1 -1
- package/dist/web/assets/{Cost-Cz6F4MAu.js → Cost-r7D19VSG.js} +1 -1
- package/dist/web/assets/{Data-RSpfLC9W.js → Data-CRttp4iM.js} +1 -1
- package/dist/web/assets/{Desktop-C0VftUUl.js → Desktop-DcaKyfKA.js} +1 -1
- package/dist/web/assets/{DesktopReview-BTYnwZKB.js → DesktopReview-BjplTYfH.js} +1 -1
- package/dist/web/assets/{Evidence-DxfTgGLn.js → Evidence-BAAKcK0h.js} +1 -1
- package/dist/web/assets/{Explore-BKAnJ0AP.js → Explore-D_RZhVAc.js} +1 -1
- package/dist/web/assets/{Features-YYcKT5mB.js → Features-B6azjGtN.js} +1 -1
- package/dist/web/assets/{Flags-B23vWmDR.js → Flags-BQR4dRaK.js} +1 -1
- package/dist/web/assets/{Flaky-kuhde8PW.js → Flaky-Ci1bvglt.js} +1 -1
- package/dist/web/assets/{Impact-DetuURYY.js → Impact-CPB7NjQF.js} +1 -1
- package/dist/web/assets/{Jobs-BTiCqtr9.js → Jobs-CR8SxpWA.js} +1 -1
- package/dist/web/assets/{KindPage-BbL7COME.js → KindPage-Bl7q-2b8.js} +1 -1
- package/dist/web/assets/{Migration-CPv7gDC-.js → Migration-BecNlszU.js} +1 -1
- package/dist/web/assets/{Product-DcrBguCI.js → Product-AMUC5arL.js} +1 -1
- package/dist/web/assets/{Production-N11W9Ckr.js → Production-CZ-EG3t2.js} +1 -1
- package/dist/web/assets/{Quality-DzXW1cvp.js → Quality-k2U9v2Dn.js} +1 -1
- package/dist/web/assets/{Readiness-BbHO8wa2.js → Readiness-D3_S6lDT.js} +1 -1
- package/dist/web/assets/Record-Ba6XRn7c.js +2 -0
- package/dist/web/assets/{Regression-BOSQ2Pxp.js → Regression-jpkQRkt_.js} +1 -1
- package/dist/web/assets/{Reports-BA1VdwoC.js → Reports-BHKtb9Oi.js} +1 -1
- package/dist/web/assets/{Response-0i0ww7OC.js → Response-CVNWGdun.js} +1 -1
- package/dist/web/assets/{RunDiff-D-4tB7Is.js → RunDiff-dbcFibiJ.js} +1 -1
- package/dist/web/assets/{Runs-DW7dZh2j.js → Runs-ij-80l3A.js} +1 -1
- package/dist/web/assets/{TestCases-BfPkdwR6.js → TestCases-BW8laQ_8.js} +1 -1
- package/dist/web/assets/{TestData-DRoJc7Me.js → TestData-0f1XzLdc.js} +1 -1
- package/dist/web/assets/{TestDebt-ly8BsLSJ.js → TestDebt-C-2y3RTV.js} +1 -1
- package/dist/web/assets/{Tosca-CzrCAhEs.js → Tosca-DnfpS6Zf.js} +1 -1
- package/dist/web/assets/{WhatsNew-Cd8D1O1X.js → WhatsNew-C1HUalPw.js} +1 -1
- package/dist/web/assets/{dataParts-DzHf4K4-.js → dataParts-DWD2uUxL.js} +1 -1
- package/dist/web/assets/{fold-CyU-Mjqe.js → fold-o_l3hXTU.js} +1 -1
- package/dist/web/assets/frame-CdUL-UeQ.js +4 -0
- package/dist/web/assets/{index-Bv3atkwB.js → index-BmJOj6t1.js} +5 -5
- package/dist/web/assets/index-DP3riJZe.css +2 -0
- package/dist/web/assets/{logos-cftOc5MX.js → logos-CMkTgBD8.js} +1 -1
- package/dist/web/assets/{palette-D_SCreF2.js → palette-D-wSuihi.js} +1 -1
- package/dist/web/assets/{qualityParts-50E_QRTX.js → qualityParts-DS83Q0nG.js} +1 -1
- package/dist/web/assets/{rows-JZ5MvdCQ.js → rows-DYYObxPx.js} +1 -1
- package/dist/web/assets/{thread-CrExMoMY.js → thread-Cnjdo5ve.js} +1 -1
- package/dist/web/assets/{usePageChat-DpnA7edC.js → usePageChat-DWmmQrbC.js} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/py/forgeqe_engine/capture.py +14 -1
- package/py/forgeqe_engine/memory.py +18 -4
- package/py/forgeqe_engine/recordsession.py +211 -15
- package/py/forgeqe_engine/varying.py +120 -0
- package/py/forgeqe_engine/webrecord.py +115 -32
- package/py/forgeqe_engine/webrecord_page.py +199 -29
- package/py/forgeqe_engine/workflow_yaml.py +18 -1
- package/dist/web/assets/Record-P7TKcE5d.js +0 -2
- package/dist/web/assets/frame-DUo0M0VF.js +0 -4
- package/dist/web/assets/index-DwUumNPZ.css +0 -2
|
@@ -35,6 +35,11 @@ FORMAT_SOURCE = "recorded"
|
|
|
35
35
|
# A page that loads this soon after a click, a key, or a typed value came from it, not from the address bar (for a
|
|
36
36
|
# navigation the browser did not report as the page's own).
|
|
37
37
|
NAV_CAUSED_SECONDS = 1.5
|
|
38
|
+
# A back the page's own script did (a "Back" button's history.back()) starts at once after the click; a person's back
|
|
39
|
+
# (the browser's button, Alt+Left) comes later, however soon. Counted from when the page began to load.
|
|
40
|
+
BACK_CAUSED_SECONDS = 0.4
|
|
41
|
+
# How far down a scroll's end may be kept, in pixels.
|
|
42
|
+
MAX_SCROLL_END = 10_000_000
|
|
38
43
|
DOUBLE_CLICK_SECONDS = 0.5
|
|
39
44
|
MAX_TEXT = 200
|
|
40
45
|
EXPECT_KINDS = ("text", "visible", "hidden", "value", "checked", "url", "title", "intent")
|
|
@@ -148,6 +153,9 @@ def var_name(text: str, taken: Any = ()) -> str:
|
|
|
148
153
|
return name
|
|
149
154
|
|
|
150
155
|
|
|
156
|
+
_ENV_NAME = re.compile(r"^[A-Z_][A-Z0-9_]{0,99}$")
|
|
157
|
+
|
|
158
|
+
|
|
151
159
|
def secret_env_for(host: str) -> str:
|
|
152
160
|
"""The variable a recorded password is read from when no saved login names one: shop.example.com → SHOP_EXAMPLE_COM_PASSWORD."""
|
|
153
161
|
base = _ENV.sub("_", (host or "SITE").upper()).strip("_") or "SITE"
|
|
@@ -228,7 +236,9 @@ def element_step(op: str, t: Target) -> Dict[str, Any]:
|
|
|
228
236
|
**({"position": dict(t.position)} if t.position else {}),
|
|
229
237
|
**({"shadow": "closed"} if t.closed_shadow else {}),
|
|
230
238
|
"locators": [
|
|
231
|
-
|
|
239
|
+
# generated/live_data: why this one scored low (a framework's id, a name holding data that changes). The
|
|
240
|
+
# review shows it on the step and the handoff never offers it to the coding agent as a safe one.
|
|
241
|
+
{"type": l["type"], "value": l["value"], "confidence": l.get("confidence"), **{k: l[k] for k in ("css", "attr", "verified", "within", "generated", "live_data", "varies") if l.get(k)}}
|
|
232
242
|
for l in locs
|
|
233
243
|
if l.get("type") and l.get("value")
|
|
234
244
|
],
|
|
@@ -239,6 +249,16 @@ def element_step(op: str, t: Target) -> Dict[str, Any]:
|
|
|
239
249
|
}
|
|
240
250
|
|
|
241
251
|
|
|
252
|
+
# Locator kinds that carry what an element says: when one of these was seen holding other words on another load of the
|
|
253
|
+
# same page, the words themselves are what changed, not only the way the element is found.
|
|
254
|
+
_SAYS = ("text", "text_pattern", "role", "role_pattern", "label", "title", "alt")
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def _varies_text(t: Target) -> bool:
|
|
258
|
+
"""Whether this element said something else when the recording loaded the same page again (varying.py)."""
|
|
259
|
+
return any(l.get("varies") and l.get("type") in _SAYS for l in t.locators)
|
|
260
|
+
|
|
261
|
+
|
|
242
262
|
def auto_name(steps: List[Dict[str, Any]], start_url: str, limit: int = 4) -> str:
|
|
243
263
|
"""
|
|
244
264
|
A recording's name when the tester gave none: the site, then what was done, in the words of the controls used
|
|
@@ -283,6 +303,8 @@ def describe(step: Dict[str, Any]) -> str:
|
|
|
283
303
|
return f"press {step.get('keys')}"
|
|
284
304
|
if op == "back":
|
|
285
305
|
return "go back"
|
|
306
|
+
if op == "leave":
|
|
307
|
+
return "move the pointer off the page (through its top)"
|
|
286
308
|
if op == "wait_for":
|
|
287
309
|
return f"wait for {label}"
|
|
288
310
|
if op == "captcha":
|
|
@@ -365,6 +387,8 @@ class WebRecorder:
|
|
|
365
387
|
login_values: Mapping[str, str] = field(default_factory=dict)
|
|
366
388
|
# The password variable of each saved login, by the hosts it signs in to.
|
|
367
389
|
login_passwords: Mapping[str, str] = field(default_factory=dict)
|
|
390
|
+
# When the event being handled happened, on the clock (recordsession sets it per event): None for now.
|
|
391
|
+
event_at: Optional[float] = None
|
|
368
392
|
clock: Callable[[], float] = lambda: 0.0
|
|
369
393
|
# The test case being recorded: its steps ({n, action, expected}), shown as a checklist; each recorded step belongs
|
|
370
394
|
# to the case step the tester is on.
|
|
@@ -384,18 +408,24 @@ class WebRecorder:
|
|
|
384
408
|
|
|
385
409
|
# -- what the tester did ----------------------------------------------------------------------------------------
|
|
386
410
|
|
|
387
|
-
def on_navigate(self, url: str, how: str = "") -> Optional[str]:
|
|
411
|
+
def on_navigate(self, url: str, how: str = "", *, started: Optional[float] = None, by_page: bool = False, at: Optional[float] = None) -> Optional[str]:
|
|
388
412
|
"""
|
|
389
413
|
A page loaded in the tab: `how` is "page" (the page itself navigated: a link, a form, a script), "reload",
|
|
390
|
-
"back", "forward", or "" (the address bar, a bookmark).
|
|
414
|
+
"back", "forward", or "" (the address bar, a bookmark). `started`: when it began to load (the recorder's clock);
|
|
415
|
+
`by_page`: the page asked for it.
|
|
391
416
|
"""
|
|
392
417
|
if not url.startswith(("http://", "https://")):
|
|
393
418
|
return None
|
|
394
|
-
at = self.clock()
|
|
419
|
+
at = at if at is not None else self.clock()
|
|
395
420
|
previous, self.url = self.url, url
|
|
396
|
-
|
|
421
|
+
# The same address again is a reload, unless it is a back or forward to another entry (a form's result page
|
|
422
|
+
# back to the form, both at /upload).
|
|
423
|
+
if how == "reload" or (url == previous and how not in ("back", "forward")):
|
|
397
424
|
return None
|
|
398
425
|
caused = how == "page" or at - self._last_action <= NAV_CAUSED_SECONDS
|
|
426
|
+
if how == "back":
|
|
427
|
+
# The person's back, unless the page asked for it or it began with the click (the page's own Back button).
|
|
428
|
+
caused = by_page or (started if started is not None else at) - self._last_action <= BACK_CAUSED_SECONDS
|
|
399
429
|
if how == "back" and not caused:
|
|
400
430
|
if self.paused:
|
|
401
431
|
return None
|
|
@@ -408,10 +438,14 @@ class WebRecorder:
|
|
|
408
438
|
self._add({"op": "navigate", "url": url})
|
|
409
439
|
return f"open {url}"
|
|
410
440
|
|
|
411
|
-
def on_click(self, t: Target, *, hover: Optional[Target] = None, right: bool = False) -> Optional[str]:
|
|
441
|
+
def on_click(self, t: Target, *, hover: Optional[Target] = None, right: bool = False, held: Optional[int] = None, outer_hovers: Optional[List[Target]] = None) -> Optional[str]:
|
|
442
|
+
"""
|
|
443
|
+
A click; `hover`: the trigger the pointer was on to show it (a menu's), `outer_hovers` the ones before that (a
|
|
444
|
+
menu inside a menu, outermost first); `held`: how long the button was held, in ms, when it was a long press.
|
|
445
|
+
"""
|
|
412
446
|
if self.paused:
|
|
413
447
|
return None
|
|
414
|
-
at = self.
|
|
448
|
+
at = self._now()
|
|
415
449
|
self._last_action = at
|
|
416
450
|
if right:
|
|
417
451
|
# A right-click (the page's own context menu): never half of a double-click.
|
|
@@ -428,31 +462,56 @@ class WebRecorder:
|
|
|
428
462
|
self._last_click = None
|
|
429
463
|
return describe(self.steps[-1])
|
|
430
464
|
if hover is not None and hover.key != t.key:
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
465
|
+
for h in [*(outer_hovers or []), hover]:
|
|
466
|
+
prev = self.steps[-1]
|
|
467
|
+
if h.key != t.key and not (prev.get("op") == "hover" and _same(prev, h)):
|
|
468
|
+
self._add({**element_step("hover", h), "inferred": True})
|
|
469
|
+
step = element_step("click", t)
|
|
470
|
+
if isinstance(held, int) and not isinstance(held, bool) and 600 <= held <= 10000:
|
|
471
|
+
step["hold_ms"] = held
|
|
472
|
+
self._add(step)
|
|
435
473
|
self._last_click = (t.key, at)
|
|
436
474
|
return describe(self.steps[-1])
|
|
437
475
|
|
|
438
|
-
def on_scroll(self, down: bool, pages: float, box: Optional[Target] = None) -> Optional[str]:
|
|
476
|
+
def on_scroll(self, down: bool, pages: float, box: Optional[Target] = None, *, end: Optional[int] = None, small: bool = False) -> Optional[str]:
|
|
439
477
|
"""
|
|
440
478
|
The page (or `box`, a list that scrolls on its own) scrolled by the person, by screens: one step for scrolls
|
|
441
|
-
one after another the same way in the same place. A replay scrolls as far, so what loads on a scroll loads
|
|
479
|
+
one after another the same way in the same place. A replay scrolls as far, so what loads on a scroll loads;
|
|
480
|
+
`end` (where it ended, in pixels from the top) takes it to the same place, wherever the steps before left it.
|
|
481
|
+
A `small` scroll (less than half a screen) is no step: it only moves where the scroll just before it ended.
|
|
442
482
|
"""
|
|
443
483
|
if self.paused or not 0 < pages <= 50:
|
|
444
484
|
return None
|
|
445
|
-
self._last_action = self.
|
|
485
|
+
self._last_action = self._now()
|
|
446
486
|
self._last_click = None
|
|
447
487
|
prev = self.steps[-1]
|
|
448
488
|
same_place = (box is None and not prev.get("locators")) or (box is not None and _same(prev, box))
|
|
489
|
+
if small:
|
|
490
|
+
if prev.get("op") == "scroll" and same_place and end is not None and 0 <= end <= MAX_SCROLL_END:
|
|
491
|
+
prev["end"] = end
|
|
492
|
+
return None
|
|
449
493
|
if prev.get("op") == "scroll" and bool(prev.get("down", True)) == down and same_place:
|
|
450
494
|
prev["pages"] = round(min(50.0, float(prev.get("pages") or 0) + pages), 1)
|
|
495
|
+
if end is not None and 0 <= end <= MAX_SCROLL_END:
|
|
496
|
+
prev["end"] = end
|
|
497
|
+
else:
|
|
498
|
+
prev.pop("end", None)
|
|
451
499
|
return describe(prev)
|
|
452
500
|
step: Dict[str, Any] = {**(element_step("scroll", box) if box is not None else {"op": "scroll", "page": page_id(self.url) or self.url}), "down": down, "pages": round(pages, 1)}
|
|
501
|
+
if end is not None and 0 <= end <= MAX_SCROLL_END:
|
|
502
|
+
step["end"] = end
|
|
453
503
|
self._add(step)
|
|
454
504
|
return describe(step)
|
|
455
505
|
|
|
506
|
+
def on_leave(self) -> Optional[str]:
|
|
507
|
+
"""The pointer left the page through its top and the page showed something for it (an exit-intent offer)."""
|
|
508
|
+
if self.paused or self.steps[-1].get("op") == "leave":
|
|
509
|
+
return None
|
|
510
|
+
self._last_action = self._now()
|
|
511
|
+
self._last_click = None
|
|
512
|
+
self._add({"op": "leave", "page": page_id(self.url) or self.url})
|
|
513
|
+
return describe(self.steps[-1])
|
|
514
|
+
|
|
456
515
|
def on_hover(self, t: Target, *, inferred: bool = False) -> Optional[str]:
|
|
457
516
|
"""
|
|
458
517
|
A hover kept as a step: by the hover command (the element the pointer is on), or before a check of what only a
|
|
@@ -463,7 +522,7 @@ class WebRecorder:
|
|
|
463
522
|
prev = self.steps[-1]
|
|
464
523
|
if prev.get("op") == "hover" and _same(prev, t):
|
|
465
524
|
return None
|
|
466
|
-
self._last_action = self.
|
|
525
|
+
self._last_action = self._now()
|
|
467
526
|
self._last_click = None
|
|
468
527
|
self._add({**element_step("hover", t), **({"inferred": True} if inferred else {})})
|
|
469
528
|
return describe(self.steps[-1])
|
|
@@ -475,7 +534,7 @@ class WebRecorder:
|
|
|
475
534
|
"""
|
|
476
535
|
if self.paused:
|
|
477
536
|
return None
|
|
478
|
-
self._last_action = self.
|
|
537
|
+
self._last_action = self._now()
|
|
479
538
|
self._last_click = None
|
|
480
539
|
if self.steps[-1].get("op") == "captcha" and self.steps[-1].get("provider") == provider:
|
|
481
540
|
return None
|
|
@@ -492,7 +551,7 @@ class WebRecorder:
|
|
|
492
551
|
file = download_name(name)
|
|
493
552
|
if not file:
|
|
494
553
|
return None
|
|
495
|
-
self._last_action = self.
|
|
554
|
+
self._last_action = self._now()
|
|
496
555
|
self._last_click = None
|
|
497
556
|
step: Dict[str, Any] = {"op": "download", "file": file, "page": page_id(self.url) or self.url}
|
|
498
557
|
pattern = dynamic.pattern_of(file, anchored=True)
|
|
@@ -511,7 +570,7 @@ class WebRecorder:
|
|
|
511
570
|
"""
|
|
512
571
|
if self.paused or kind not in DIALOG_KINDS:
|
|
513
572
|
return None
|
|
514
|
-
self._last_action = self.
|
|
573
|
+
self._last_action = self._now()
|
|
515
574
|
self._last_click = None
|
|
516
575
|
step: Dict[str, Any] = {"op": "dialog", "kind": kind, "message": dialog_message(message), "accept": bool(accept), "page": page_id(self.url) or self.url}
|
|
517
576
|
if kind == "prompt" and accept:
|
|
@@ -533,7 +592,7 @@ class WebRecorder:
|
|
|
533
592
|
"""
|
|
534
593
|
if self.paused:
|
|
535
594
|
return None
|
|
536
|
-
self._last_action = self.
|
|
595
|
+
self._last_action = self._now()
|
|
537
596
|
self._last_click = None
|
|
538
597
|
step = element_step("drag", t)
|
|
539
598
|
if to is not None and not _same_element(t, to):
|
|
@@ -550,7 +609,7 @@ class WebRecorder:
|
|
|
550
609
|
"""The browser's own double-click event: the two clicks before it on the element become one double-click."""
|
|
551
610
|
if self.paused:
|
|
552
611
|
return None
|
|
553
|
-
self._last_action = self.
|
|
612
|
+
self._last_action = self._now()
|
|
554
613
|
if self.steps[-1].get("op") == "dblclick" and _same(self.steps[-1], t):
|
|
555
614
|
return None
|
|
556
615
|
while len(self.steps) > 1 and self.steps[-1].get("op") == "click" and _same(self.steps[-1], t):
|
|
@@ -559,11 +618,14 @@ class WebRecorder:
|
|
|
559
618
|
self._last_click = None
|
|
560
619
|
return describe(self.steps[-1])
|
|
561
620
|
|
|
562
|
-
def on_fill(self, t: Target, value: Optional[str], *, password: bool = False) -> Optional[str]:
|
|
563
|
-
"""
|
|
621
|
+
def on_fill(self, t: Target, value: Optional[str], *, password: bool = False, secret_env: Optional[str] = None) -> Optional[str]:
|
|
622
|
+
"""
|
|
623
|
+
The final text of a field the tester typed in; `value` is None for a password field (never sent). `secret_env`:
|
|
624
|
+
the variable the password is read from, when the recorder could tell (recordsession._typed_password_env).
|
|
625
|
+
"""
|
|
564
626
|
if self.paused:
|
|
565
627
|
return None
|
|
566
|
-
self._last_action = self.
|
|
628
|
+
self._last_action = self._now()
|
|
567
629
|
self._last_click = None
|
|
568
630
|
# The click that put the caret in the field, and an earlier fill of the same field just before: one step.
|
|
569
631
|
while len(self.steps) > 1 and self.steps[-1].get("op") in ("click", "input") and _same(self.steps[-1], t):
|
|
@@ -572,7 +634,7 @@ class WebRecorder:
|
|
|
572
634
|
step["clear"] = True
|
|
573
635
|
host = urlparse(t.url).hostname or ""
|
|
574
636
|
if password or value is None:
|
|
575
|
-
env = self._password_env(host)
|
|
637
|
+
env = secret_env if secret_env and _ENV_NAME.match(secret_env) else self._password_env(host)
|
|
576
638
|
step.update(text="", text_env=env)
|
|
577
639
|
if env not in self.secrets:
|
|
578
640
|
self.secrets.append(env)
|
|
@@ -590,15 +652,22 @@ class WebRecorder:
|
|
|
590
652
|
self._add(step)
|
|
591
653
|
return describe(step)
|
|
592
654
|
|
|
593
|
-
def on_select(self, t: Target, text: str) -> Optional[str]:
|
|
655
|
+
def on_select(self, t: Target, text: str, *, options: Optional[List[Any]] = None) -> Optional[str]:
|
|
656
|
+
"""
|
|
657
|
+
A choice in a select list; `options`: what a list that takes many has chosen (their labels, one line each), one
|
|
658
|
+
step however many clicks it took.
|
|
659
|
+
"""
|
|
594
660
|
if self.paused:
|
|
595
661
|
return None
|
|
596
|
-
self._last_action = self.
|
|
662
|
+
self._last_action = self._now()
|
|
597
663
|
self._last_click = None
|
|
598
|
-
|
|
664
|
+
chosen = [_clip(" ".join(o.split())) for o in options[:50] if isinstance(o, str) and o.strip()] if options is not None else None
|
|
665
|
+
while len(self.steps) > 1 and self.steps[-1].get("op") in ("click", "select") and _same(self.steps[-1], t) and (self.steps[-1].get("op") == "click" or chosen is not None):
|
|
599
666
|
self.steps.pop()
|
|
600
667
|
step = element_step("select", t)
|
|
601
|
-
step["text"] = _clip(text)
|
|
668
|
+
step["text"] = _clip(", ".join(chosen) if chosen is not None else text)
|
|
669
|
+
if chosen is not None:
|
|
670
|
+
step["options"] = chosen
|
|
602
671
|
self._add(step)
|
|
603
672
|
return describe(step)
|
|
604
673
|
|
|
@@ -608,9 +677,13 @@ class WebRecorder:
|
|
|
608
677
|
key = keys.split("+")[-1]
|
|
609
678
|
if in_field and "+" not in keys and key not in FIELD_KEYS and not (autocomplete and key in AUTOCOMPLETE_KEYS):
|
|
610
679
|
return None
|
|
611
|
-
self._last_action = self.
|
|
680
|
+
self._last_action = self._now()
|
|
612
681
|
self._last_click = None
|
|
613
|
-
|
|
682
|
+
step: Dict[str, Any] = {"op": "press", "keys": keys}
|
|
683
|
+
# An arrow key in a field that suggests as it is typed in: the replay waits for the suggestions first.
|
|
684
|
+
if in_field and autocomplete and key in AUTOCOMPLETE_KEYS and self.steps[-1].get("op") in ("input", "press"):
|
|
685
|
+
step["suggestions"] = True
|
|
686
|
+
self._add(step)
|
|
614
687
|
return describe(self.steps[-1])
|
|
615
688
|
|
|
616
689
|
def on_upload(self, t: Target, files: List[str], refused: List[str], *, run_files: Optional[List[str]] = None, drop: bool = False) -> Optional[str]:
|
|
@@ -621,7 +694,7 @@ class WebRecorder:
|
|
|
621
694
|
"""
|
|
622
695
|
if self.paused:
|
|
623
696
|
return None
|
|
624
|
-
self._last_action = self.
|
|
697
|
+
self._last_action = self._now()
|
|
625
698
|
self._last_click = None
|
|
626
699
|
for why in refused:
|
|
627
700
|
self._skip("upload", why)
|
|
@@ -644,7 +717,7 @@ class WebRecorder:
|
|
|
644
717
|
def on_unsupported(self, action: str, reason: str) -> str:
|
|
645
718
|
"""Something the tester did that cannot be a step yet (an upload, a drag): listed in the result."""
|
|
646
719
|
if not self.paused:
|
|
647
|
-
self._last_action = self.
|
|
720
|
+
self._last_action = self._now()
|
|
648
721
|
return self._skip(action, reason)
|
|
649
722
|
|
|
650
723
|
# -- what the tester added ----------------------------------------------------------------------------------------
|
|
@@ -679,6 +752,12 @@ class WebRecorder:
|
|
|
679
752
|
if made is not None:
|
|
680
753
|
step["text"] = made["text"]
|
|
681
754
|
elif kind in ("text", "value") and text:
|
|
755
|
+
# The page showed something else here when the recording loaded it again (varying.py): a message picked at
|
|
756
|
+
# random, a greeting that rotates. A check that spells out this load's words fails on the next, whatever
|
|
757
|
+
# the words look like, so it is live data even where dynamic.py finds nothing data-shaped in them.
|
|
758
|
+
if t is not None and _varies_text(t):
|
|
759
|
+
step["varies"] = True
|
|
760
|
+
dynamic = True
|
|
682
761
|
self._live(step, text, explicit=dynamic)
|
|
683
762
|
step["source"] = source
|
|
684
763
|
self._add(step)
|
|
@@ -873,6 +952,10 @@ class WebRecorder:
|
|
|
873
952
|
|
|
874
953
|
# -- helpers ------------------------------------------------------------------------------------------------------
|
|
875
954
|
|
|
955
|
+
def _now(self) -> float:
|
|
956
|
+
"""When the event being recorded happened (recordsession stamps it as it arrives), else now."""
|
|
957
|
+
return self.event_at if self.event_at is not None else self.clock()
|
|
958
|
+
|
|
876
959
|
def _password_env(self, host: str) -> str:
|
|
877
960
|
host = host.lower()
|
|
878
961
|
for hosts, env in self.login_passwords.items():
|