@empiricalrun/test-gen 0.38.8 → 0.38.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.38.10
4
+
5
+ ### Patch Changes
6
+
7
+ - e3f04e6: fix: add support for injecting script before agent action
8
+
9
+ ## 0.38.9
10
+
11
+ ### Patch Changes
12
+
13
+ - 134f282: fix: annotations position after scroll
14
+
3
15
  ## 0.38.8
4
16
 
5
17
  ### Patch Changes
@@ -313,20 +313,18 @@ function annotateClickableElements(options = {}) {
313
313
  var parentElements = [];
314
314
 
315
315
  // Create a hint marker
316
- function createHintMarker(el, hint, parentElement) {
316
+ function createHintMarker(el, hint, parentElement, windowToAnnotate) {
317
317
  const rect = el.getBoundingClientRect();
318
- const parentRect = parentElement.getBoundingClientRect();
319
318
 
320
319
  // Create the marker element
321
320
  const marker = document.createElement("div");
322
321
  marker.textContent = hint;
323
322
  marker.className = markerClass;
324
-
325
323
  // Style the marker
326
324
  Object.assign(marker.style, {
327
325
  position: "absolute",
328
- top: `${rect.top + parentRect.top}px`,
329
- left: `${rect.left + parentRect.left}px`,
326
+ top: `${rect.top + windowToAnnotate.scrollY}px`,
327
+ left: `${rect.left + windowToAnnotate.scrollX}px`,
330
328
  background:
331
329
  "-webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(255, 247, 133)), to(rgb(255, 197, 66)))",
332
330
  padding: "1px 3px 0px",
@@ -389,7 +387,7 @@ function annotateClickableElements(options = {}) {
389
387
  const rect = el.getBoundingClientRect();
390
388
 
391
389
  // Use createHintMarker with the specified container
392
- createHintMarker(el, hint, container);
390
+ createHintMarker(el, hint, container, windowToAnnotate);
393
391
  el.style.boxShadow = `inset 0 0 0px 2px red`;
394
392
 
395
393
  // Add element details to the annotations map
@@ -189,9 +189,9 @@ async function createTestUsingMasterAgent({ task, page, testCase, options, scope
189
189
  page = actions.getStateVariables()[plannerResp.pageName];
190
190
  // update page in actions
191
191
  testGenPage.updatePage({ page, name: plannerResp.pageName });
192
- // inject scripts in the updated
193
- await (0, utils_2.injectPwLocatorGenerator)(testGenPage.pwPageInstance);
194
192
  }
193
+ // inject scripts in the page
194
+ await (0, utils_2.injectPwLocatorGenerator)(testGenPage.pwPageInstance);
195
195
  const buffer = await page.screenshot({
196
196
  //This is done to improve element annotation accuracy, anyways it doesn't annotate elements which are out of viewport
197
197
  // fullPage: true,
@@ -313,20 +313,18 @@ function annotateClickableElements(options = {}) {
313
313
  var parentElements = [];
314
314
 
315
315
  // Create a hint marker
316
- function createHintMarker(el, hint, parentElement) {
316
+ function createHintMarker(el, hint, parentElement, windowToAnnotate) {
317
317
  const rect = el.getBoundingClientRect();
318
- const parentRect = parentElement.getBoundingClientRect();
319
318
 
320
319
  // Create the marker element
321
320
  const marker = document.createElement("div");
322
321
  marker.textContent = hint;
323
322
  marker.className = markerClass;
324
-
325
323
  // Style the marker
326
324
  Object.assign(marker.style, {
327
325
  position: "absolute",
328
- top: `${rect.top + parentRect.top}px`,
329
- left: `${rect.left + parentRect.left}px`,
326
+ top: `${rect.top + windowToAnnotate.scrollY}px`,
327
+ left: `${rect.left + windowToAnnotate.scrollX}px`,
330
328
  background:
331
329
  "-webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(255, 247, 133)), to(rgb(255, 197, 66)))",
332
330
  padding: "1px 3px 0px",
@@ -389,7 +387,7 @@ function annotateClickableElements(options = {}) {
389
387
  const rect = el.getBoundingClientRect();
390
388
 
391
389
  // Use createHintMarker with the specified container
392
- createHintMarker(el, hint, container);
390
+ createHintMarker(el, hint, container, windowToAnnotate);
393
391
  el.style.boxShadow = `inset 0 0 0px 2px red`;
394
392
 
395
393
  // Add element details to the annotations map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.38.8",
3
+ "version": "0.38.10",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -58,9 +58,9 @@
58
58
  "ts-morph": "^23.0.0",
59
59
  "tsx": "^4.16.2",
60
60
  "typescript": "^5.3.3",
61
- "@empiricalrun/llm": "^0.9.25",
62
61
  "@empiricalrun/r2-uploader": "^0.3.6",
63
- "@empiricalrun/reporter": "^0.21.3"
62
+ "@empiricalrun/reporter": "^0.21.3",
63
+ "@empiricalrun/llm": "^0.9.25"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/detect-port": "^1.3.5",