@testivai/witness-selenium 0.3.12 → 0.4.0

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 (2) hide show
  1. package/dist/witness.js +6 -1
  2. package/package.json +2 -2
package/dist/witness.js CHANGED
@@ -291,10 +291,13 @@ async function witness(driver, name, options = {}) {
291
291
  // side. The injected function is the SAME one the Playwright adapter
292
292
  // uses (`@testivai/witness`), so both lanes produce identical maps.
293
293
  // Selenium's executeScript needs an explicit `return`.
294
+ // Opt-in: paths anchored on attributes such as data-testid (config
295
+ // `elementIdAttributes`), recorded with the capture only when set.
296
+ const idAttributes = (0, witness_1.normalizeElementIdAttributes)(localConfig.elementIdAttributes);
294
297
  let elementMap;
295
298
  if (!options.skipElementMap && typeof driver.executeScript === 'function') {
296
299
  try {
297
- const expr = (0, witness_1.buildElementMapExpression)(options.maxElements ?? witness_1.DEFAULT_MAX_ELEMENTS, ignoreSelectors);
300
+ const expr = (0, witness_1.buildElementMapExpression)(options.maxElements ?? witness_1.DEFAULT_MAX_ELEMENTS, ignoreSelectors, idAttributes);
298
301
  const result = await driver.executeScript(`return ${expr}`);
299
302
  if (Array.isArray(result) && result.length > 0) {
300
303
  elementMap = result;
@@ -335,6 +338,8 @@ async function witness(driver, name, options = {}) {
335
338
  try {
336
339
  fs.mkdirSync(tempDir, { recursive: true });
337
340
  fs.writeFileSync(path.join(tempDir, 'elements.json'), JSON.stringify(elementMap));
341
+ if (idAttributes.length > 0)
342
+ store.writeTempMetadata(name, { elementIdAttributes: idAttributes });
338
343
  }
339
344
  catch {
340
345
  // A map we cannot persist is not worth failing a capture over.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testivai/witness-selenium",
3
- "version": "0.3.12",
3
+ "version": "0.4.0",
4
4
  "description": "Selenium WebDriver adapter for TestivAI Witness — local-first visual regression with pixel + DOM comparison",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -49,7 +49,7 @@
49
49
  }
50
50
  },
51
51
  "dependencies": {
52
- "@testivai/witness": "2.5.0"
52
+ "@testivai/witness": "2.6.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/jest": "^30.0.0",