Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit ada3555

Browse files
committed
fix: wait selectors
1 parent e42de87 commit ada3555

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules
22
recordings/*
33
yarn-error.log
44
.DS_Store
5-
dist
5+
dist
6+
owloops/e2e

src/OwloopsStringifyExtension.ts

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,6 @@ function filterArrayByString(selectors: Schema.Selector[], value: string) {
281281
);
282282
}
283283

284-
function filterArrayByStringForWaitForElementStep(selectors: string[], value: string) {
285-
return selectors.filter((selector) =>
286-
value === "aria/"
287-
? !selector.includes(value)
288-
: selector.includes(value)
289-
);
290-
}
291-
292284
function handleSelectors(
293285
selectors: Schema.Selector[],
294286
flow?: Schema.UserFlow
@@ -312,27 +304,16 @@ function handleSelectors(
312304
}
313305

314306
function handleSelectorsForWaitForElementStep(
315-
selectors: string[],
307+
selectors: Array<string[] | string>,
316308
flow?: Schema.UserFlow
317309
): string | undefined {
318-
// Remove Aria selectors in favor of DOM selectors
319-
const nonAriaSelectors = filterArrayByStringForWaitForElementStep(selectors, "aria/");
320-
321-
let preferredSelector;
310+
const allSelectors = selectors.flat().filter(Boolean);
322311

323-
// Give preference to user-specified selectors
324-
if (flow?.selectorAttribute) {
325-
preferredSelector = filterArrayByStringForWaitForElementStep(
326-
nonAriaSelectors,
327-
flow.selectorAttribute
328-
);
329-
}
312+
const chosenSelector = allSelectors.find(selector =>
313+
selector.startsWith(flow?.selectorAttribute ?? '')
314+
) ?? allSelectors[0];
330315

331-
if (preferredSelector && preferredSelector.length > 0) {
332-
return formatAsJSLiteral(preferredSelector[0]);
333-
} else {
334-
return formatAsJSLiteral(nonAriaSelectors[0]);
335-
}
316+
return formatAsJSLiteral(chosenSelector);
336317
}
337318

338319
function ariaSelectors(selectors: Schema.Selector[]): string | undefined {

0 commit comments

Comments
 (0)