@@ -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-
292284function handleSelectors (
293285 selectors : Schema . Selector [ ] ,
294286 flow ?: Schema . UserFlow
@@ -312,27 +304,16 @@ function handleSelectors(
312304}
313305
314306function 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
338319function ariaSelectors ( selectors : Schema . Selector [ ] ) : string | undefined {
0 commit comments