automation_model 1.0.594-dev → 1.0.596-dev

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.
@@ -7,10 +7,9 @@ import path from "path";
7
7
  import reg_parser from "regex-parser";
8
8
  import { findDateAlternatives, findNumberAlternatives } from "./analyze_helper.js";
9
9
  import { getDateTimeValue } from "./date_time.js";
10
- import drawRectangle from "./drawRect.js";
11
10
  //import { closeUnexpectedPopups } from "./popups.js";
12
11
  import { getTableCells, getTableData } from "./table_analyze.js";
13
- import { _convertToRegexQuery, _copyContext, _fixLocatorUsingParams, _fixUsingParams, _getServerUrl, KEYBOARD_EVENTS, maskValue, replaceWithLocalTestData, scrollPageToLoadLazyElements, unEscapeString, } from "./utils.js";
12
+ import { _convertToRegexQuery, _copyContext, _fixLocatorUsingParams, _fixUsingParams, _getServerUrl, extractStepExampleParameters, KEYBOARD_EVENTS, maskValue, replaceWithLocalTestData, scrollPageToLoadLazyElements, unEscapeString, } from "./utils.js";
14
13
  import csv from "csv-parser";
15
14
  import { Readable } from "node:stream";
16
15
  import readline from "readline";
@@ -253,7 +252,7 @@ class StableBrowser {
253
252
  highlight: false,
254
253
  };
255
254
  try {
256
- await _preCommand(state, this);
255
+ await _preCommand(state, this, world);
257
256
  await this.page.goto(url, {
258
257
  timeout: 60000,
259
258
  });
@@ -827,7 +826,7 @@ class StableBrowser {
827
826
  operation: "simpleClick",
828
827
  log: "***** click on " + elementDescription + " *****\n",
829
828
  };
830
- _preCommand(state, this);
829
+ _preCommand(state, this, world);
831
830
  const startTime = Date.now();
832
831
  let timeout = 30000;
833
832
  if (options && options.timeout) {
@@ -876,7 +875,7 @@ class StableBrowser {
876
875
  operation: "simpleClickType",
877
876
  log: "***** click type on " + elementDescription + " *****\n",
878
877
  };
879
- _preCommand(state, this);
878
+ _preCommand(state, this, world);
880
879
  const startTime = Date.now();
881
880
  let timeout = 30000;
882
881
  if (options && options.timeout) {
@@ -924,7 +923,7 @@ class StableBrowser {
924
923
  log: "***** click on " + selectors.element_name + " *****\n",
925
924
  };
926
925
  try {
927
- await _preCommand(state, this);
926
+ await _preCommand(state, this, world);
928
927
  // if (state.options && state.options.context) {
929
928
  // state.selectors.locators[0].text = state.options.context;
930
929
  // }
@@ -960,14 +959,20 @@ class StableBrowser {
960
959
  log: "***** check " + selectors.element_name + " *****\n",
961
960
  };
962
961
  try {
963
- await _preCommand(state, this);
962
+ await _preCommand(state, this, world);
964
963
  state.info.checked = checked;
965
964
  // let element = await this._locate(selectors, info, _params);
966
965
  // ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info));
967
966
  try {
968
- // await this._highlightElements(element);
967
+ if (world && world.screenshot && !world.screenshotPath) {
968
+ // console.log(`Highlighting while running from recorder`);
969
+ await this._highlightElements(element);
970
+ await new Promise((resolve) => setTimeout(resolve, 100));
971
+ await this._unHighlightElements(element);
972
+ }
969
973
  await state.element.setChecked(checked);
970
- await new Promise((resolve) => setTimeout(resolve, 1000));
974
+ // await new Promise((resolve) => setTimeout(resolve, 1000));
975
+ // await this._unHighlightElements(element);
971
976
  }
972
977
  catch (e) {
973
978
  if (e.message && e.message.includes("did not change its state")) {
@@ -1003,9 +1008,10 @@ class StableBrowser {
1003
1008
  log: "***** hover " + selectors.element_name + " *****\n",
1004
1009
  };
1005
1010
  try {
1006
- await _preCommand(state, this);
1011
+ await _preCommand(state, this, world);
1007
1012
  try {
1008
1013
  await state.element.hover();
1014
+ await _screenshot(state, this);
1009
1015
  await new Promise((resolve) => setTimeout(resolve, 1000));
1010
1016
  }
1011
1017
  catch (e) {
@@ -1013,9 +1019,10 @@ class StableBrowser {
1013
1019
  state.info.log += "hover failed, will try again" + "\n";
1014
1020
  state.element = await this._locate(selectors, state.info, _params);
1015
1021
  await state.element.hover({ timeout: 10000 });
1022
+ await _screenshot(state, this);
1016
1023
  await new Promise((resolve) => setTimeout(resolve, 1000));
1017
1024
  }
1018
- await _screenshot(state, this);
1025
+ // await _screenshot(state, this);
1019
1026
  await this.waitForPageLoad();
1020
1027
  return state.info;
1021
1028
  }
@@ -1042,7 +1049,7 @@ class StableBrowser {
1042
1049
  log: "***** select option " + selectors.element_name + " *****\n",
1043
1050
  };
1044
1051
  try {
1045
- await _preCommand(state, this);
1052
+ await _preCommand(state, this, world);
1046
1053
  try {
1047
1054
  await state.element.selectOption(values);
1048
1055
  }
@@ -1076,7 +1083,7 @@ class StableBrowser {
1076
1083
  log: "",
1077
1084
  };
1078
1085
  try {
1079
- await _preCommand(state, this);
1086
+ await _preCommand(state, this, world);
1080
1087
  const valueSegment = state.value.split("&&");
1081
1088
  for (let i = 0; i < valueSegment.length; i++) {
1082
1089
  if (i > 0) {
@@ -1119,7 +1126,7 @@ class StableBrowser {
1119
1126
  log: "***** set input value " + selectors.element_name + " *****\n",
1120
1127
  };
1121
1128
  try {
1122
- await _preCommand(state, this);
1129
+ await _preCommand(state, this, world);
1123
1130
  let value = await this._replaceWithLocalData(state.value, this);
1124
1131
  try {
1125
1132
  await state.element.evaluateHandle((el, value) => {
@@ -1156,7 +1163,7 @@ class StableBrowser {
1156
1163
  throwError: false,
1157
1164
  };
1158
1165
  try {
1159
- await _preCommand(state, this);
1166
+ await _preCommand(state, this, world);
1160
1167
  try {
1161
1168
  await state.element.click();
1162
1169
  await new Promise((resolve) => setTimeout(resolve, 500));
@@ -1230,7 +1237,7 @@ class StableBrowser {
1230
1237
  _value = newValue;
1231
1238
  }
1232
1239
  try {
1233
- await _preCommand(state, this);
1240
+ await _preCommand(state, this, world);
1234
1241
  state.info.value = _value;
1235
1242
  if (options === null || options === undefined || !options.press) {
1236
1243
  try {
@@ -1323,7 +1330,7 @@ class StableBrowser {
1323
1330
  log: "***** fill on " + selectors.element_name + " with value " + value + "*****\n",
1324
1331
  };
1325
1332
  try {
1326
- await _preCommand(state, this);
1333
+ await _preCommand(state, this, world);
1327
1334
  await state.element.fill(value);
1328
1335
  await state.element.dispatchEvent("change");
1329
1336
  if (enter) {
@@ -1369,9 +1376,19 @@ class StableBrowser {
1369
1376
  catch (e) {
1370
1377
  //ignore
1371
1378
  }
1372
- ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info));
1379
+ ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info, element));
1373
1380
  try {
1374
- await this._highlightElements(element);
1381
+ if (world && world.screenshot && !world.screenshotPath) {
1382
+ // console.log(`Highlighting for get text while running from recorder`);
1383
+ this._highlightElements(element)
1384
+ .then(async () => {
1385
+ await new Promise((resolve) => setTimeout(resolve, 1000));
1386
+ this._unhighlightElements(element).then(() => { }
1387
+ // console.log(`Unhighlighting vrtr in recorder is successful`)
1388
+ );
1389
+ })
1390
+ .catch(e);
1391
+ }
1375
1392
  const elementText = await element.innerText();
1376
1393
  return {
1377
1394
  text: elementText,
@@ -1383,7 +1400,7 @@ class StableBrowser {
1383
1400
  }
1384
1401
  catch (e) {
1385
1402
  //await this.closeUnexpectedPopups();
1386
- this.logger.info("no innerText will use textContent");
1403
+ this.logger.info("no innerText, will use textContent");
1387
1404
  const elementText = await element.textContent();
1388
1405
  return { text: elementText, screenshotId, screenshotPath, value: value };
1389
1406
  }
@@ -1418,13 +1435,13 @@ class StableBrowser {
1418
1435
  }
1419
1436
  let foundObj = null;
1420
1437
  try {
1421
- await _preCommand(state, this);
1438
+ await _preCommand(state, this, world);
1422
1439
  state.info.pattern = pattern;
1423
1440
  foundObj = await this._getText(selectors, 0, _params, options, state.info, world);
1424
1441
  if (foundObj && foundObj.element) {
1425
1442
  await this.scrollIfNeeded(foundObj.element, state.info);
1426
1443
  }
1427
- await _screenshot(state, this);
1444
+ await _screenshot(state, this, foundObj.element);
1428
1445
  let escapedText = text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1429
1446
  pattern = pattern.replace("{text}", escapedText);
1430
1447
  let regex = new RegExp(pattern, "im");
@@ -1469,12 +1486,12 @@ class StableBrowser {
1469
1486
  }
1470
1487
  let foundObj = null;
1471
1488
  try {
1472
- await _preCommand(state, this);
1489
+ await _preCommand(state, this, world);
1473
1490
  foundObj = await this._getText(selectors, climb, _params, options, state.info, world);
1474
1491
  if (foundObj && foundObj.element) {
1475
1492
  await this.scrollIfNeeded(foundObj.element, state.info);
1476
1493
  }
1477
- await _screenshot(state, this);
1494
+ await _screenshot(state, this, foundObj.element);
1478
1495
  const dateAlternatives = findDateAlternatives(text);
1479
1496
  const numberAlternatives = findNumberAlternatives(text);
1480
1497
  if (dateAlternatives.date) {
@@ -1663,7 +1680,7 @@ class StableBrowser {
1663
1680
  }
1664
1681
  return data;
1665
1682
  }
1666
- async _screenShot(options = {}, world = null, info = null) {
1683
+ async _screenShot(options = {}, world = null, info = null, focusedElement = null) {
1667
1684
  // collect url/path/title
1668
1685
  if (info) {
1669
1686
  if (!info.title) {
@@ -1692,7 +1709,7 @@ class StableBrowser {
1692
1709
  const uuidStr = "id_" + randomUUID();
1693
1710
  const screenshotPath = path.join(world.screenshotPath, uuidStr + ".png");
1694
1711
  try {
1695
- await this.takeScreenshot(screenshotPath);
1712
+ await this.takeScreenshot(screenshotPath, focusedElement);
1696
1713
  // let buffer = await this.page.screenshot({ timeout: 4000 });
1697
1714
  // // save the buffer to the screenshot path asynchrously
1698
1715
  // fs.writeFile(screenshotPath, buffer, (err) => {
@@ -1703,7 +1720,7 @@ class StableBrowser {
1703
1720
  result.screenshotId = uuidStr;
1704
1721
  result.screenshotPath = screenshotPath;
1705
1722
  if (info && info.box) {
1706
- await drawRectangle(screenshotPath, info.box.x, info.box.y, info.box.width, info.box.height);
1723
+ // await drawRectangle(screenshotPath, info.box.x, info.box.y, info.box.width, info.box.height);
1707
1724
  }
1708
1725
  }
1709
1726
  catch (e) {
@@ -1713,7 +1730,7 @@ class StableBrowser {
1713
1730
  else if (options && options.screenshot) {
1714
1731
  result.screenshotPath = options.screenshotPath;
1715
1732
  try {
1716
- await this.takeScreenshot(options.screenshotPath);
1733
+ await this.takeScreenshot(options.screenshotPath, focusedElement);
1717
1734
  // let buffer = await this.page.screenshot({ timeout: 4000 });
1718
1735
  // // save the buffer to the screenshot path asynchrously
1719
1736
  // fs.writeFile(options.screenshotPath, buffer, (err) => {
@@ -1726,12 +1743,12 @@ class StableBrowser {
1726
1743
  this.logger.info("unable to take screenshot, ignored");
1727
1744
  }
1728
1745
  if (info && info.box) {
1729
- await drawRectangle(options.screenshotPath, info.box.x, info.box.y, info.box.width, info.box.height);
1746
+ // await drawRectangle(options.screenshotPath, info.box.x, info.box.y, info.box.width, info.box.height);
1730
1747
  }
1731
1748
  }
1732
1749
  return result;
1733
1750
  }
1734
- async takeScreenshot(screenshotPath) {
1751
+ async takeScreenshot(screenshotPath, focusedElement = null) {
1735
1752
  const playContext = this.context.playContext;
1736
1753
  // Using CDP to capture the screenshot
1737
1754
  const viewportWidth = Math.max(...(await this.page.evaluate(() => [
@@ -1743,6 +1760,15 @@ class StableBrowser {
1743
1760
  document.documentElement.clientWidth,
1744
1761
  ])));
1745
1762
  let screenshotBuffer = null;
1763
+ // if (focusedElement) {
1764
+ // // console.log(`Focused element ${JSON.stringify(focusedElement._selector)}`)
1765
+ // await this._unhighlightElements(focusedElement);
1766
+ // await new Promise((resolve) => setTimeout(resolve, 100));
1767
+ // console.log(`Unhighlighted previous element`);
1768
+ // }
1769
+ if (focusedElement) {
1770
+ await this._highlightElements(focusedElement);
1771
+ }
1746
1772
  if (this.context.browserName === "chromium") {
1747
1773
  const client = await playContext.newCDPSession(this.page);
1748
1774
  const { data } = await client.send("Page.captureScreenshot", {
@@ -1764,6 +1790,10 @@ class StableBrowser {
1764
1790
  else {
1765
1791
  screenshotBuffer = await this.page.screenshot();
1766
1792
  }
1793
+ if (focusedElement) {
1794
+ // console.log(`Focused element ${JSON.stringify(focusedElement._selector)}`)
1795
+ await this._unhighlightElements(focusedElement);
1796
+ }
1767
1797
  let image = await Jimp.read(screenshotBuffer);
1768
1798
  // Get the image dimensions
1769
1799
  const { width, height } = image.bitmap;
@@ -1790,7 +1820,7 @@ class StableBrowser {
1790
1820
  };
1791
1821
  await new Promise((resolve) => setTimeout(resolve, 2000));
1792
1822
  try {
1793
- await _preCommand(state, this);
1823
+ await _preCommand(state, this, world);
1794
1824
  await expect(state.element).toHaveCount(1, { timeout: 10000 });
1795
1825
  return state.info;
1796
1826
  }
@@ -1816,7 +1846,7 @@ class StableBrowser {
1816
1846
  };
1817
1847
  await new Promise((resolve) => setTimeout(resolve, 2000));
1818
1848
  try {
1819
- await _preCommand(state, this);
1849
+ await _preCommand(state, this, world);
1820
1850
  switch (attribute) {
1821
1851
  case "inner_text":
1822
1852
  state.value = await state.element.innerText();
@@ -1834,6 +1864,7 @@ class StableBrowser {
1834
1864
  state.info.value = state.value;
1835
1865
  this.setTestData({ [variable]: state.value }, world);
1836
1866
  this.logger.info("set test data: " + variable + "=" + state.value);
1867
+ await new Promise((resolve) => setTimeout(resolve, 500));
1837
1868
  return state.info;
1838
1869
  }
1839
1870
  catch (e) {
@@ -1862,7 +1893,7 @@ class StableBrowser {
1862
1893
  await new Promise((resolve) => setTimeout(resolve, 2000));
1863
1894
  let val;
1864
1895
  try {
1865
- await _preCommand(state, this);
1896
+ await _preCommand(state, this, world);
1866
1897
  switch (attribute) {
1867
1898
  case "innerText":
1868
1899
  val = String(await state.element.innerText());
@@ -1995,27 +2026,33 @@ class StableBrowser {
1995
2026
  async _highlightElements(scope, css) {
1996
2027
  try {
1997
2028
  if (!scope) {
2029
+ // console.log(`Scope is not defined`);
1998
2030
  return;
1999
2031
  }
2000
2032
  if (!css) {
2001
2033
  scope
2002
2034
  .evaluate((node) => {
2003
2035
  if (node && node.style) {
2004
- let originalBorder = node.style.outline;
2036
+ let originalOutline = node.style.outline;
2037
+ // console.log(`Original outline was: ${originalOutline}`);
2038
+ node.__previousOutline = originalOutline;
2005
2039
  node.style.outline = "2px solid red";
2006
- if (window) {
2007
- window.addEventListener("beforeunload", function (e) {
2008
- node.style.outline = originalBorder;
2009
- });
2010
- }
2011
- setTimeout(function () {
2012
- node.style.outline = originalBorder;
2013
- }, 2000);
2040
+ // console.log(`New outline is: ${node.style.outline}`);
2041
+ // if (window) {
2042
+ // window.addEventListener("beforeunload", function (e) {
2043
+ // node.style.outline = originalBorder;
2044
+ // });
2045
+ // }
2046
+ // setTimeout(function () {
2047
+ // node.style.outline = originalBorder;
2048
+ //}, 2000);
2014
2049
  }
2015
2050
  })
2016
- .then(() => { })
2051
+ .then(() => {
2052
+ })
2017
2053
  .catch((e) => {
2018
2054
  // ignore
2055
+ // console.error(`Could not highlight node : ${e}`);
2019
2056
  });
2020
2057
  }
2021
2058
  else {
@@ -2031,24 +2068,27 @@ class StableBrowser {
2031
2068
  if (!element.style) {
2032
2069
  return;
2033
2070
  }
2034
- var originalBorder = element.style.outline;
2071
+ let originalOutline = element.style.outline;
2072
+ element.__previousOutline = originalOutline;
2035
2073
  // Set the new border to be red and 2px solid
2036
2074
  element.style.outline = "2px solid red";
2037
- if (window) {
2038
- window.addEventListener("beforeunload", function (e) {
2039
- element.style.outline = originalBorder;
2040
- });
2041
- }
2075
+ // if (window) {
2076
+ // window.addEventListener("beforeunload", function (e) {
2077
+ // element.style.outline = originalBorder;
2078
+ // });
2079
+ // }
2042
2080
  // Set a timeout to revert to the original border after 2 seconds
2043
- setTimeout(function () {
2044
- element.style.outline = originalBorder;
2045
- }, 2000);
2081
+ // setTimeout(function () {
2082
+ // element.style.outline = originalBorder;
2083
+ // }, 2000);
2046
2084
  }
2047
2085
  return;
2048
2086
  }, [css])
2049
- .then(() => { })
2087
+ .then(() => {
2088
+ })
2050
2089
  .catch((e) => {
2051
2090
  // ignore
2091
+ // console.error(`Could not highlight css: ${e}`);
2052
2092
  });
2053
2093
  }
2054
2094
  }
@@ -2056,6 +2096,60 @@ class StableBrowser {
2056
2096
  console.debug(error);
2057
2097
  }
2058
2098
  }
2099
+ async _unhighlightElements(scope, css) {
2100
+ try {
2101
+ if (!scope) {
2102
+ return;
2103
+ }
2104
+ if (!css) {
2105
+ scope
2106
+ .evaluate((node) => {
2107
+ if (node && node.style) {
2108
+ if (!node.__previousOutline) {
2109
+ node.style.outline = "";
2110
+ }
2111
+ else {
2112
+ node.style.outline = node.__previousOutline;
2113
+ }
2114
+ }
2115
+ })
2116
+ .then(() => {
2117
+ })
2118
+ .catch((e) => {
2119
+ // console.log(`Error while unhighlighting node ${JSON.stringify(scope)}: ${e}`);
2120
+ });
2121
+ }
2122
+ else {
2123
+ scope
2124
+ .evaluate(([css]) => {
2125
+ if (!css) {
2126
+ return;
2127
+ }
2128
+ let elements = Array.from(document.querySelectorAll(css));
2129
+ for (i = 0; i < elements.length; i++) {
2130
+ let element = elements[i];
2131
+ if (!element.style) {
2132
+ return;
2133
+ }
2134
+ if (!element.__previousOutline) {
2135
+ element.style.outline = "";
2136
+ }
2137
+ else {
2138
+ element.style.outline = element.__previousOutline;
2139
+ }
2140
+ }
2141
+ })
2142
+ .then(() => {
2143
+ })
2144
+ .catch((e) => {
2145
+ // console.error(`Error while unhighlighting element in css: ${e}`);
2146
+ });
2147
+ }
2148
+ }
2149
+ catch (error) {
2150
+ // console.debug(error);
2151
+ }
2152
+ }
2059
2153
  async verifyPagePath(pathPart, options = {}, world = null) {
2060
2154
  const startTime = Date.now();
2061
2155
  let error = null;
@@ -2170,7 +2264,7 @@ class StableBrowser {
2170
2264
  let dateAlternatives = findDateAlternatives(text);
2171
2265
  let numberAlternatives = findNumberAlternatives(text);
2172
2266
  try {
2173
- await _preCommand(state, this);
2267
+ await _preCommand(state, this, world);
2174
2268
  state.info.text = text;
2175
2269
  while (true) {
2176
2270
  const resultWithElementsFound = await this.findTextInAllFrames(dateAlternatives, numberAlternatives, text, state);
@@ -2184,14 +2278,31 @@ class StableBrowser {
2184
2278
  if (resultWithElementsFound[0].randomToken) {
2185
2279
  const frame = resultWithElementsFound[0].frame;
2186
2280
  const dataAttribute = `[data-blinq-id-${resultWithElementsFound[0].randomToken}]`;
2187
- await this._highlightElements(frame, dataAttribute);
2281
+ if (world && world.screenshot && !world.screenshotPath) {
2282
+ // console.log(`Highlighting for verify text is found while running from recorder`);
2283
+ this._highlightElements(frame, dataAttribute).then(async () => {
2284
+ await new Promise((resolve) => setTimeout(resolve, 1000));
2285
+ this._unhighlightElements(frame, dataAttribute)
2286
+ .then(async () => {
2287
+ // console.log(`Unhighlighted frame dataAttribute successfully`);
2288
+ })
2289
+ .catch((e) => { }
2290
+ // console.error(e)
2291
+ );
2292
+ });
2293
+ }
2188
2294
  const element = await frame.locator(dataAttribute).first();
2295
+ // await new Promise((resolve) => setTimeout(resolve, 100));
2296
+ // await this._unhighlightElements(frame, dataAttribute);
2189
2297
  if (element) {
2190
2298
  await this.scrollIfNeeded(element, state.info);
2191
2299
  await element.dispatchEvent("bvt_verify_page_contains_text");
2300
+ await _screenshot(state, this, element);
2192
2301
  }
2193
2302
  }
2194
- await _screenshot(state, this);
2303
+ else {
2304
+ await _screenshot(state, this);
2305
+ }
2195
2306
  return state.info;
2196
2307
  }
2197
2308
  // await expect(element).toHaveCount(1, { timeout: 10000 });
@@ -2227,7 +2338,7 @@ class StableBrowser {
2227
2338
  let dateAlternatives = findDateAlternatives(text);
2228
2339
  let numberAlternatives = findNumberAlternatives(text);
2229
2340
  try {
2230
- await _preCommand(state, this);
2341
+ await _preCommand(state, this, world);
2231
2342
  state.info.text = text;
2232
2343
  while (true) {
2233
2344
  const resultWithElementsFound = await this.findTextInAllFrames(dateAlternatives, numberAlternatives, text, state);
@@ -2279,7 +2390,7 @@ class StableBrowser {
2279
2390
  let numberAlternatives = findNumberAlternatives(textToVerify);
2280
2391
  let foundAncore = false;
2281
2392
  try {
2282
- await _preCommand(state, this);
2393
+ await _preCommand(state, this, world);
2283
2394
  state.info.text = textToVerify;
2284
2395
  while (true) {
2285
2396
  const resultWithElementsFound = await this.findTextInAllFrames(dateAlternatives, numberAlternatives, textAnchor, state);
@@ -2309,14 +2420,29 @@ class StableBrowser {
2309
2420
  if (result.elementCount > 0) {
2310
2421
  const dataAttribute = "[data-blinq-id-" + result.randomToken + "]";
2311
2422
  //const cssAnchor = `[data-blinq-id="blinq-id-${token}-anchor"]`;
2312
- await this._highlightElements(frame, dataAttribute);
2423
+ if (world && world.screenshot && !world.screenshotPath) {
2424
+ // console.log(`Highlighting for vtrt while running from recorder`);
2425
+ this._highlightElements(frame, dataAttribute)
2426
+ .then(async () => {
2427
+ await new Promise((resolve) => setTimeout(resolve, 1000));
2428
+ this._unhighlightElements(frame, dataAttribute).then(() => { }
2429
+ // console.log(`Unhighlighting vrtr in recorder is successful`)
2430
+ );
2431
+ })
2432
+ .catch(e);
2433
+ }
2313
2434
  //await this._highlightElements(frame, cssAnchor);
2314
2435
  const element = await frame.locator(dataAttribute).first();
2436
+ // await new Promise((resolve) => setTimeout(resolve, 100));
2437
+ // await this._unhighlightElements(frame, dataAttribute);
2315
2438
  if (element) {
2316
2439
  await this.scrollIfNeeded(element, state.info);
2317
2440
  await element.dispatchEvent("bvt_verify_page_contains_text");
2441
+ await _screenshot(state, this, element);
2442
+ }
2443
+ else {
2444
+ await _screenshot(state, this);
2318
2445
  }
2319
- await _screenshot(state, this);
2320
2446
  return state.info;
2321
2447
  }
2322
2448
  }
@@ -2439,14 +2565,14 @@ class StableBrowser {
2439
2565
  info.selectors = selectors;
2440
2566
  try {
2441
2567
  let table = await this._locate(selectors, info, _params);
2442
- ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info));
2568
+ ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info, table));
2443
2569
  const tableData = await getTableData(this.page, table);
2444
2570
  return tableData;
2445
2571
  }
2446
2572
  catch (e) {
2447
2573
  this.logger.error("getTableData failed " + info.log);
2448
2574
  this.logger.error(e);
2449
- ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info));
2575
+ ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info, table));
2450
2576
  info.screenshotPath = screenshotPath;
2451
2577
  Object.assign(e, { info: info });
2452
2578
  error = e;
@@ -2727,7 +2853,7 @@ class StableBrowser {
2727
2853
  throwError: false,
2728
2854
  };
2729
2855
  try {
2730
- await _preCommand(state, this);
2856
+ await _preCommand(state, this, world);
2731
2857
  await this.page.close();
2732
2858
  }
2733
2859
  catch (e) {
@@ -2856,6 +2982,9 @@ class StableBrowser {
2856
2982
  else {
2857
2983
  this.stepName = "step " + this.stepIndex;
2858
2984
  }
2985
+ if (this.context) {
2986
+ this.context.examplesRow = extractStepExampleParameters(step);
2987
+ }
2859
2988
  if (this.context && this.context.browserObject && this.context.browserObject.trace === true) {
2860
2989
  if (this.context.browserObject.context) {
2861
2990
  await this.context.browserObject.context.tracing.startChunk({ title: this.stepName });
@@ -2878,6 +3007,9 @@ class StableBrowser {
2878
3007
  });
2879
3008
  }
2880
3009
  }
3010
+ if (this.context) {
3011
+ this.context.examplesRow = null;
3012
+ }
2881
3013
  }
2882
3014
  }
2883
3015
  function createTimedPromise(promise, label) {