def f(context, page_name): return { switch.get('NAVIGATION'): pages.NavigationPage(context), switch.get('HOME_PAGE'): pages.HomePage(context), switch.get('RESULT_PAGE'): pages.ResultPage(context), switch.get('IDA_PAGE'): pages.IdaPage(context), switch.get('VOLTA_PAGE'): pages.VoltaPage(context) }[page_name]
def set_mother_page(page): """Set the Mother Page to all the pages On most of the applications, the mother page is the Home/Landing/Welcome screen. So, may not have several code lines here. """ if page == switch.get('PAGENAME_SCREEN'): BasePage.mother_page = switch.get('PAGENAME_SCREEN')
def navigate_to(self, context, page): if page == navigation_switch.get('HOME_PAGE'): # Desired page pass elif page == navigation_switch.get('IDA_PAGE'): # Desired page self.element_tap(home_switch.get('IDA_BUTTON'), 'button', 40, HomePage_locators) elif page == navigation_switch.get('VOLTA_PAGE'): # Desired page self.element_tap(home_switch.get('VOLTA_BUTTON'), 'button', 40, HomePage_locators)
def given_user_accessed_signin_from(context, current_page, desired_page): context.page = get_page_navigation(context, 'Navigation') context.page.navigate_to(context, desired_page) if desired_page == navigation_switch.get('HOME_SCREEN'): context.page.element_tap(home_switch.get('SIGNIN_BUTTON'), 'button', 40, HomePage_locators) elif desired_page == navigation_switch.get('MYTRIPS_SCREEN'): context.page.element_tap(mytrips_switch.get('SIGNIN_BUTTON'), 'button', 40, MyTripsPage_locators) elif desired_page == navigation_switch.get('MORE_SCREEN'): context.page.element_tap(more_switch.get('SIGNIN_BUTTON'), 'button', 40, MorePage_locators) context.page = get_page_object(context, current_page) context.page.page_is_displayed()
def navigate_to(self, context, page): if page == navigation_switch.get('HOME_SCREEN'): # Desired page pass elif page == navigation_switch.get('MYTRIPS_SCREEN'): self.element_tap(home_switch.get('MYTRIPS_BUTTON'), 'button', 40, HomePage_locators) elif page == navigation_switch.get('MORE_SCREEN'): self.element_tap(home_switch.get('MORE_BUTTON'), 'button', 40, HomePage_locators) elif page == navigation_switch.get('SIGNIN_SCREEN'): self.element_tap(home_switch.get('SIGNIN_BUTTON'), 'button', 40, HomePage_locators)
def when_user_selects_day(context, day): current_page = get_page_context() if current_page == navigation_switch.get('IDA_PAGE'): context.page.element_tap(ida_switch.get('DAY_BUTTON'), 'button', 40, IdaPage_locators) else: context.page.element_tap(volta_switch.get('DAY_BUTTON'), 'button', 40, VoltaPage_locators)
def when_user_selects_month(context, month): current_page = get_page_context() if current_page == navigation_switch.get('IDA_PAGE'): context.page.select(ida_switch.get('MONTH_BUTTON'), 'button', ida_switch.get(month), 40) else: context.page.select(volta_switch.get('MONTH_BUTTON'), 'button', volta_switch.get(month), 40)
def given_user_authenticated(context, page): given_app_displays_page(context, page) def fill_fields(context): context.page.element_tap(signin_switch.get('USERNAME_BUTTON'), 'button', 40, SigninPage_locators) context.page.send_value(signin_switch.get('USERNAME_FIELD'), 'label', signin_switch.get('VALID_USERNAME'), 40, SigninPage_locators) context.page.element_tap(signin_switch.get('PASSWORD_BUTTON'), 'button', 40, SigninPage_locators) context.page.send_value(signin_switch.get('PASSWORD_FIELD'), 'label', signin_switch.get('VALID_PASSWORD'), 40, SigninPage_locators) context.page.element_tap(signin_switch.get('SIGNIN_BUTTON'), 'button', 40, SigninPage_locators) if page == navigation_switch.get('HOME_SCREEN'): context.page.element_tap(home_switch.get('SIGNIN_BUTTON'), 'button', 40, HomePage_locators) fill_fields(context) elif page == navigation_switch.get('MYTRIPS_SCREEN'): context.page.element_tap(mytrips_switch.get('SIGNIN_BUTTON'), 'button', 40, MyTripsPage_locators) fill_fields(context) elif page == navigation_switch.get('MORE_SCREEN'): context.page.element_tap(more_switch.get('SIGNIN_BUTTON'), 'button', 40, MorePage_locators) fill_fields(context)
def f(context, page_name): return { switch.get('NAVIGATION'): pages.NavigationPage(context), switch.get('HOME_SCREEN'): pages.HomePage(context), switch.get('MYTRIPS_SCREEN'): pages.MyTripsPage(context), switch.get('MORE_SCREEN'): pages.MorePage(context), switch.get('SIGNIN_SCREEN'): pages.SigninPage(context), switch.get('FORGOTPASSWORD_SCREEN'): pages.ForgotpasswordPage(context), switch.get('FORGOTUSERNAME_SCREEN'): pages.ForgotusernamePage(context), switch.get('HAWAIIANMILLES_SCREEN'): pages.HawaiianmillesPage(context) }[page_name]
def when_user_selects_day_from_home(context, day, prompt): current_page = get_page_context() context.page = get_page_navigation(context, 'Navigation') context.page.navigate_to(context, prompt) if prompt == navigation_switch.get('IDA_PAGE'): context.page.element_tap(ida_switch.get('DAY_BUTTON'), 'button', 40, IdaPage_locators) else: context.page.element_tap(volta_switch.get('DAY_BUTTON'), 'button', 40, VoltaPage_locators) context.page.navigate_to(context, current_page) context.page = get_page_object(context, current_page)
def when_user_selects_month_from_home(context, month, prompt): current_page = get_page_context() context.page = get_page_navigation(context, 'Navigation') context.page.navigate_to(context, prompt) if prompt == navigation_switch.get('IDA_PAGE'): context.page.select(ida_switch.get('MONTH_BUTTON'), 'button', ida_switch.get(month), 40, IdaPage_locators) else: context.page.select(volta_switch.get('MONTH_BUTTON'), 'button', volta_switch.get(month), 40, VoltaPage_locators) context.page.navigate_to(context, current_page) context.page = get_page_object(context, current_page)
def before_feature(context, feature): BasePage.set_page_name(switch.get('HOME_SCREEN')) BasePage.set_mother_page(switch.get('HOME_SCREEN'))
def before_feature(context, feature): BasePage.set_page_name(navigation_switch.get('HOME_PAGE'))