import { $ , $$ , browser , by , element , ElementFinder } from 'protractor' ; export class WizardPage { wizard = $ ( 'ux-wizard' ) ; stepHeaders = $$ ( '.wizard-step' ) ; stepContents = $$ ( 'ux-wizard-step' ) ; buttons = $$ ( 'ux-wizard button' ) ; addStep5Button = $ ( '#addStep5' ) ; removeStep5Button = $ ( '#removeStep5' ) ; footerTemplateButton = element ( by . id ( 'footerTemplate' ) ) ; resetButton = element ( by . id ( 'reset' ) ) ; step1InvalidButton = element ( by . id ( 'step1Invalid' ) ) ; step4InvalidButton = element ( by . id ( 'step4Invalid' ) ) ; step2InvalidButton = element ( by . id ( 'step2Invalid' ) ) ; disableNextWhenInvalidWizardButton = element ( by . id ( 'disableNextWhenInvalidWizard' ) ) ; disableNextWhenInvalidStep1Button = element ( by . id ( 'disableNextWhenInvalidStep1' ) ) ; async getPage ( ) { await browser . get ( '#/wizard' ) ; } async getButtonByText ( text ) { let buttons = await this . buttons ; let btnText = await this . buttons . map ( button => button . getText ( ) ) ; let matchIdx = btnText . findIndex ( ( label ) => label . toLowerCase ( ) === text . toLowerCase ( ) ) ; return matchIdx === - 1 ? null : buttons [ matchIdx ] ; } async getPreviousButton ( ) { return await this . getButtonByText ( 'Previous' ) ; } async getNextButton ( ) { return await this . getButtonByText ( 'Next' ) ; } async getCancelButton ( ) { return await this . getButtonByText ( 'Cancel' ) ; } async getFinishButton ( ) { return await this . getButtonByText ( 'Finish' ) ; } async goToNext ( ) { const next = await this . getNextButton ( ) ; return await next . click ( ) ; } async goToPrevious ( ) { const prev = await this . getPreviousButton ( ) ; return await prev . click ( ) ; } async addStep5 ( ) { return await this . addStep5Button . click ( ) ; } async removeStep5 ( ) { return await this . removeStep5Button . click ( ) ; } }