@@ -30,6 +30,8 @@ export class LumaMainPage extends BasePage {
3030 private dialogFooterLocator = '[class="modal-footer"]' ;
3131 private loggedInAttributeLocator = '.logged-in' ;
3232 private accountDownArrowButtonLocator = '[class="panel header"] .customer-welcome'
33+ protected searchBarLocator = '#search' ;
34+ private searchResultList = '#search_autocomplete' ;
3335
3436 public async chooseMenuBarOption ( menuBarItem : MenuBar ) {
3537 let menuBarValue = this . page . locator ( this . navigationMenuBar , { hasText : new RegExp ( `^\\${ menuBarItem . valueOf ( ) } \\b$` , 'i' ) } ) ;
@@ -359,4 +361,19 @@ export class LumaMainPage extends BasePage {
359361 throw new Error ( `user may be signed out and therefore the account options are not available` )
360362 }
361363 }
364+
365+ public async searchFor ( item : string , options ?: { pressEnter ?: boolean } ) {
366+ const searchBar = this . page . locator ( this . searchBarLocator ) ;
367+ await this . fillText ( searchBar , item ) ;
368+ if ( options ?. pressEnter ) {
369+ await this . pressEnter ( ) ;
370+ return ;
371+ }
372+ const searchResults = this . page . locator ( this . searchResultList ) ;
373+ const searchResultVisiblity = await searchResults . isVisible ( ) ;
374+ if ( searchResultVisiblity ) {
375+ const searchResultListItems = this . page . locator ( this . searchResultList ) . locator ( 'li' ) ;
376+ await this . clickAndChooseFromDropdownByText ( this . searchBarLocator , searchResultListItems , item ) ;
377+ }
378+ }
362379}
0 commit comments