1+ const { I } = inject ( )
2+
13Feature ( 'Custom Locator Strategies - @Playwright' )
24
3- Before ( I => {
5+ Before ( ( ) => {
46 // Create test HTML with various attributes for custom locator testing
57 I . amOnPage ( '/form/empty' )
68 I . executeScript ( ( ) => {
@@ -71,15 +73,15 @@ Before(I => {
7173 } )
7274} )
7375
74- Scenario ( 'should find elements using byRole custom locator' , I => {
76+ Scenario ( 'should find elements using byRole custom locator' , ( { I } ) => {
7577 I . see ( 'Custom Locator Test Page' , { byRole : 'main' } )
7678 I . seeElement ( { byRole : 'form' } )
7779 I . seeElement ( { byRole : 'button' } )
7880 I . seeElement ( { byRole : 'navigation' } )
7981 I . seeElement ( { byRole : 'complementary' } )
8082} )
8183
82- Scenario ( 'should find elements using byTestId custom locator' , I => {
84+ Scenario ( 'should find elements using byTestId custom locator' , ( { I } ) => {
8385 I . see ( 'Custom Locator Test Page' , { byTestId : 'page-title' } )
8486 I . seeElement ( { byTestId : 'username-input' } )
8587 I . seeElement ( { byTestId : 'password-input' } )
@@ -88,7 +90,7 @@ Scenario('should find elements using byTestId custom locator', I => {
8890 I . seeElement ( { byTestId : 'info-text' } )
8991} )
9092
91- Scenario ( 'should find elements using byDataQa custom locator' , I => {
93+ Scenario ( 'should find elements using byDataQa custom locator' , ( { I } ) => {
9294 I . seeElement ( { byDataQa : 'test-form' } )
9395 I . seeElement ( { byDataQa : 'form-section' } )
9496 I . seeElement ( { byDataQa : 'submit-btn' } )
@@ -97,7 +99,7 @@ Scenario('should find elements using byDataQa custom locator', I => {
9799 I . seeElement ( { byDataQa : 'nav-section' } )
98100} )
99101
100- Scenario ( 'should find elements using byAriaLabel custom locator' , I => {
102+ Scenario ( 'should find elements using byAriaLabel custom locator' , ( { I } ) => {
101103 I . see ( 'Custom Locator Test Page' , { byAriaLabel : 'Welcome Message' } )
102104 I . seeElement ( { byAriaLabel : 'Username field' } )
103105 I . seeElement ( { byAriaLabel : 'Password field' } )
@@ -106,12 +108,12 @@ Scenario('should find elements using byAriaLabel custom locator', I => {
106108 I . seeElement ( { byAriaLabel : 'Information message' } )
107109} )
108110
109- Scenario ( 'should find elements using byPlaceholder custom locator' , I => {
111+ Scenario ( 'should find elements using byPlaceholder custom locator' , ( { I } ) => {
110112 I . seeElement ( { byPlaceholder : 'Enter your username' } )
111113 I . seeElement ( { byPlaceholder : 'Enter your password' } )
112114} )
113115
114- Scenario ( 'should interact with elements using custom locators' , I => {
116+ Scenario ( 'should interact with elements using custom locators' , ( { I } ) => {
115117 I . fillField ( { byTestId : 'username-input' } , 'testuser' )
116118 I . fillField ( { byPlaceholder : 'Enter your password' } , 'password123' )
117119
@@ -122,7 +124,7 @@ Scenario('should interact with elements using custom locators', I => {
122124 // Form submission would normally happen here
123125} )
124126
125- Scenario ( 'should handle multiple elements with byDataQa locator' , I => {
127+ Scenario ( 'should handle multiple elements with byDataQa locator' , ( { I } ) => {
126128 // byDataQa returns all matching elements, but interactions use the first one
127129 I . seeElement ( { byDataQa : 'form-section' } )
128130
@@ -135,7 +137,7 @@ Scenario('should handle multiple elements with byDataQa locator', I => {
135137 } )
136138} )
137139
138- Scenario ( 'should work with complex selectors and mixed locator types' , I => {
140+ Scenario ( 'should work with complex selectors and mixed locator types' , ( { I } ) => {
139141 // Test that custom locators work alongside standard ones
140142 within ( { byRole : 'form' } , ( ) => {
141143 I . seeElement ( { byTestId : 'username-input' } )
@@ -150,7 +152,7 @@ Scenario('should work with complex selectors and mixed locator types', I => {
150152 } )
151153} )
152154
153- Scenario ( 'should fail gracefully for non-existent custom locators' , I => {
155+ Scenario ( 'should fail gracefully for non-existent custom locators' , ( { I } ) => {
154156 // This should throw an error about undefined custom locator strategy
155157 try {
156158 I . seeElement ( { byCustomUndefined : 'test' } )
@@ -162,19 +164,19 @@ Scenario('should fail gracefully for non-existent custom locators', I => {
162164 }
163165} )
164166
165- Scenario ( 'should work with grabbing methods' , I => {
167+ Scenario ( 'should work with grabbing methods' , ( { I } ) => {
166168 const titleText = I . grabTextFrom ( { byTestId : 'page-title' } )
167- I . assertEqual ( titleText , 'Custom Locator Test Page' )
169+ I . expectEqual ( titleText , 'Custom Locator Test Page' )
168170
169171 const usernameValue = I . grabValueFrom ( { byAriaLabel : 'Username field' } )
170- I . assertEqual ( usernameValue , '' )
172+ I . expectEqual ( usernameValue , '' )
171173
172174 I . fillField ( { byPlaceholder : 'Enter your username' } , 'grabtest' )
173175 const newUsernameValue = I . grabValueFrom ( { byTestId : 'username-input' } )
174- I . assertEqual ( newUsernameValue , 'grabtest' )
176+ I . expectEqual ( newUsernameValue , 'grabtest' )
175177} )
176178
177- Scenario ( 'should work with waiting methods' , I => {
179+ Scenario ( 'should work with waiting methods' , ( { I } ) => {
178180 I . waitForElement ( { byRole : 'main' } , 2 )
179181 I . waitForVisible ( { byTestId : 'submit-button' } , 2 )
180182 I . waitForText ( 'Custom Locator Test Page' , 2 , { byAriaLabel : 'Welcome Message' } )
0 commit comments