Skip to content

Commit 2937e47

Browse files
committed
fix regression while trying to support Element[]
1 parent b5209e0 commit 2937e47

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/util/formatMessage.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,20 @@ export const getSelector = (el: WebdriverIO.Element | WebdriverIO.ElementArray)
1919

2020
export const getSelectors = (el: WebdriverIO.Element | WdioElements): string => {
2121

22-
const selectors = []
23-
if (Array.isArray(el)) {
24-
for (const element of el) {
25-
selectors.push(getSelectors(element))
26-
}
27-
return selectors.join(', ')
28-
}
29-
3022
let parent: WebdriverIO.ElementArray['parent'] | undefined
3123

24+
const selectors: string[] = []
3225
if (isElementArray(el)) {
3326
selectors.push(`${(el).foundWith}(\`${getSelector(el)}\`)`)
3427
parent = el.parent
3528
} else if (!Array.isArray(el)) {
3629
parent = el
30+
} else if (Array.isArray(el)) {
31+
for (const element of el) {
32+
selectors.push(getSelectors(element))
33+
}
34+
// When not having more context about the common parent, return joined selectors
35+
return selectors.join(', ')
3736
}
3837

3938
while (parent && 'selector' in parent) {

0 commit comments

Comments
 (0)