|
1 | 1 | async function findReact(matcher, locator) { |
2 | | - let _locator = `_react=${locator.react}`; |
| 2 | + // Handle both Locator objects and raw locator objects |
| 3 | + const reactLocator = locator.locator || locator |
| 4 | + let _locator = `_react=${reactLocator.react}`; |
3 | 5 | let props = ''; |
4 | 6 |
|
5 | | - if (locator.props) { |
6 | | - props += propBuilder(locator.props); |
| 7 | + if (reactLocator.props) { |
| 8 | + props += propBuilder(reactLocator.props); |
7 | 9 | _locator += props; |
8 | 10 | } |
9 | 11 | return matcher.locator(_locator).all(); |
10 | 12 | } |
11 | 13 |
|
12 | 14 | async function findVue(matcher, locator) { |
13 | | - let _locator = `_vue=${locator.vue}`; |
| 15 | + // Handle both Locator objects and raw locator objects |
| 16 | + const vueLocator = locator.locator || locator |
| 17 | + let _locator = `_vue=${vueLocator.vue}`; |
14 | 18 | let props = ''; |
15 | 19 |
|
16 | | - if (locator.props) { |
17 | | - props += propBuilder(locator.props); |
| 20 | + if (vueLocator.props) { |
| 21 | + props += propBuilder(vueLocator.props); |
18 | 22 | _locator += props; |
19 | 23 | } |
20 | 24 | return matcher.locator(_locator).all(); |
21 | 25 | } |
22 | 26 |
|
23 | 27 | async function findByPlaywrightLocator(matcher, locator) { |
24 | | - if (locator && locator.toString().includes(process.env.testIdAttribute)) return matcher.getByTestId(locator.pw.value.split('=')[1]); |
25 | | - return matcher.locator(locator.pw).all(); |
| 28 | + // Handle both Locator objects and raw locator objects |
| 29 | + const pwLocator = locator.locator || locator |
| 30 | + if (pwLocator && pwLocator.toString && pwLocator.toString().includes(process.env.testIdAttribute)) { |
| 31 | + return matcher.getByTestId(pwLocator.pw.value.split('=')[1]); |
| 32 | + } |
| 33 | + const pwValue = typeof pwLocator.pw === 'string' ? pwLocator.pw : pwLocator.pw |
| 34 | + return matcher.locator(pwValue).all(); |
26 | 35 | } |
27 | 36 |
|
28 | 37 | function propBuilder(props) { |
|
0 commit comments