@@ -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