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 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 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 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 tap_buscar(self): """You should use the tap definition from the BasePage to tap on a button from the stepDefinitions""" self.element_tap(switch.get('BUSCAR_BUTTON'), 'button', 40)
def tap_destino(self): """You should use the tap definition from the BasePage to tap on a button from the stepDefinitions""" self.element_tap(switch.get('DESTINO_LABEL'), 'label', 40)
def tap_origem(self): """You should use the tap definition from the BasePage to tap on a button from the stepDefinitions""" self.element_tap(switch.get('ORIGEM_LABEL'), 'label', 40)
def tap_volta(self): """You should use the tap definition from the BasePage to tap on a button from the stepDefinitions""" self.element_tap(switch.get('VOLTA_BUTTON'), 'button', 40)
def page_is_displayed(self): """You should use the definitons from the BasePage to check if the Page is really displayed""" self.element_is_displayed(switch.get('IDA_BUTTON'), 'button', 40)
from selenium.webdriver.common.by import By # It's importing the BasePage class, who has all the definitions that are using the Appium driver. from support.pages.base import BasePage # It's importing the way to search elements through ANDROID_UIAUTOMATOR # from support.android.ui_automator import get_text, get_description # It's importing the constants file from support.constants.home import switch locators = { 'label': { switch.get('ORIGEM_LABEL'): { 'chrome': (By.ID, 'fsc-origin-search'), 'firefox': (By.ID, 'fsc-origin-search'), 'ie': (By.NAME, 'TODO'), # TODO }, switch.get('DESTINO_LABEL'): { 'chrome': (By.ID, 'fsc-destination-search'), 'firefox': (By.ID, 'fsc-destination-search'), 'ie': (By.NAME, 'TODO'), # TODO }, switch.get('IDA_BUTTON'): { 'chrome': (By.ID, 'depart-fsc-datepicker-button'), 'firefox': (By.ID, 'depart-fsc-datepicker-button'), 'ie': (By.NAME, 'TODO'), # TODO }, switch.get('VOLTA_BUTTON'): { 'chrome': (By.ID, 'return-fsc-datepicker-button'), 'firefox': (By.ID, 'return-fsc-datepicker-button'), 'ie': (By.NAME, 'TODO'), # TODO } },
from appium.webdriver.common.mobileby import MobileBy as By # It's importing the BasePage class, who has all the definitions that are using the Appium driver. from support.pages.base import BasePage # It's importing the way to search elements through ANDROID_UIAUTOMATOR from support.android.ui_automator import get_text, get_description # It's importing the constants file from support.constants.home import switch locators = { 'label': { switch.get('ALOHA_LABEL'): { 'ios': (By.NAME, 'PRODUCTS'), 'android': (By.ANDROID_UIAUTOMATOR, get_text('Aloha\nAhiahi')) }, switch.get('LAST_LABEL'): { 'ios': (By.XPATH, '//android.view.ViewGroup[@content-desc="HomePage"]/android.view.ViewGroup/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup[2]/android.view.ViewGroup[5]/android.widget.TextView' ), 'android': (By.XPATH, '//android.view.ViewGroup[@content-desc="HomePage"]/android.view.ViewGroup/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup[2]/android.view.ViewGroup[5]/android.widget.TextView' ) } }, 'button': { switch.get('CHECKIN_BUTTON'): { 'ios': (By.ACCESSIBILITY_ID, 'HomeCheckIn'), 'android': (By.ACCESSIBILITY_ID, 'HomeCheckIn') }, switch.get('SIGNIN_BUTTON'): {