Skip to content

Commit 8dc38cd

Browse files
Copilotkobenguyent
andcommitted
Changes before error encountered
Co-authored-by: kobenguyent <[email protected]>
1 parent 31558c1 commit 8dc38cd

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

test/acceptance/custom_locators_test.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,27 +152,36 @@ Scenario('should work with complex selectors and mixed locator types', ({ I }) =
152152
})
153153
})
154154

155-
Scenario('should fail gracefully for non-existent custom locators', ({ I }) => {
155+
Scenario('should fail gracefully for non-existent custom locators', async ({ I }) => {
156156
// This should throw an error about undefined custom locator strategy
157+
let errorThrown = false
158+
let errorMessage = ''
159+
157160
try {
158-
I.seeElement({ byCustomUndefined: 'test' })
159-
throw new Error('Should have thrown an error for undefined custom locator')
161+
await I.seeElement({ byCustomUndefined: 'test' })
160162
} catch (error) {
161-
if (!error.message.includes('Please define "customLocatorStrategies"')) {
162-
throw new Error('Wrong error message: ' + error.message)
163-
}
163+
errorThrown = true
164+
errorMessage = error.message
165+
}
166+
167+
if (!errorThrown) {
168+
throw new Error('Should have thrown an error for undefined custom locator')
169+
}
170+
171+
if (!errorMessage.includes('Please define "customLocatorStrategies"')) {
172+
throw new Error('Wrong error message: ' + errorMessage)
164173
}
165174
})
166175

167-
Scenario('should work with grabbing methods', ({ I }) => {
168-
const titleText = I.grabTextFrom({ byTestId: 'page-title' })
176+
Scenario('should work with grabbing methods', async ({ I }) => {
177+
const titleText = await I.grabTextFrom({ byTestId: 'page-title' })
169178
I.expectEqual(titleText, 'Custom Locator Test Page')
170179

171-
const usernameValue = I.grabValueFrom({ byAriaLabel: 'Username field' })
180+
const usernameValue = await I.grabValueFrom({ byAriaLabel: 'Username field' })
172181
I.expectEqual(usernameValue, '')
173182

174183
I.fillField({ byPlaceholder: 'Enter your username' }, 'grabtest')
175-
const newUsernameValue = I.grabValueFrom({ byTestId: 'username-input' })
184+
const newUsernameValue = await I.grabValueFrom({ byTestId: 'username-input' })
176185
I.expectEqual(newUsernameValue, 'grabtest')
177186
})
178187

0 commit comments

Comments
 (0)