def submit_contact_details(self, customer_contact_details: dict): """ Complete and Submit the Contact Detail page :param customer_contact_details: a dictionary with the following keys: address, city, state, zipcode, phone """ if type(customer_contact_details) is not dict: raise TypeError( 'customer_info is expected to be a dictionary object. Type given was: {}' .format(type(customer_contact_details))) TextElement(self.driver, locators.PERMANENT_ADDRESS_INPUT).\ set_text(customer_contact_details['address_line_one']) TextElement(self.driver, locators.PERMANENT_ADDRESS_INPUT).send_keypress(Keys.TAB) TextElement(self.driver, locators.PERMANENT_CITY_INPUT).set_text( customer_contact_details['city']) TextElement(self.driver, locators.PERMANENT_STATE_INPUT).set_text( customer_contact_details['state']) TextElement(self.driver, locators.PERMANENT_ZIPCODE_INPUT).set_text( customer_contact_details['zipcode']) TextElement(self.driver, locators.PHONE_NUMBER_INPUT).click() TextElement(self.driver, locators.PHONE_NUMBER_INPUT).set_text( customer_contact_details['phone_number']) BaseElement(self.driver, locators.CONTACT_DETAILS_NEXT_BUTTON).click() BaseElement(self.driver, locators.VERIFY_ADDRESS_BUTTON).click() BaseElement(self.driver, locators.RYI_PAGE_TITLE).wait_until_displayed()
def submit_transfer_request(self): """ Submit a prepared and scheduled transfer request """ submit_button = BaseElement(self.driver, locators.SCHEDULE_TRANSFER_BUTTON) submit_button.click() BaseElement(self.driver, locators.RECEIPT_STATUS_TEXT).wait_until_displayed()
def show_scheduled_transfers(self): """ Show scheduled transfers """ if BaseElement(self.driver, locators.SCHEDULED_TAB_ACTIVE).not_displayed(): BaseElement(self.driver, locators.SCHEDULED_TAB).click() BaseElement(self.driver, locators.SCHEDULED_TAB_ACTIVE).wait_until_displayed()
def open_next_scheduled_transfer(self): """ Preview the next scheduled transfer """ top_transfer = BaseElement(self.driver, locators.FIRST_SCHEDULED_TRANSFER_LINK) top_transfer.click() BaseElement(self.driver, locators.RECEIPT_STATUS_TEXT).wait_until_displayed()
def submit_personal_info(self, customer_personal_info: dict): """ Complete and Submit the Personal Information page :param customer_personal_info: a dictionary that must have the following keys: first_name, last_name, date_of_birth, ssn """ if type(customer_personal_info) is not dict: raise TypeError( 'customer_info is expected to be a dictionary object. Type given was: {}' .format(type(customer_personal_info))) TextElement(self.driver, locators.DOB_INPUT).wait_until_displayed() TextElement(self.driver, locators.FIRST_NAME_INPUT).set_text( customer_personal_info['first_name']) TextElement(self.driver, locators.LAST_NAME_INPUT).click() TextElement(self.driver, locators.LAST_NAME_INPUT).set_text( customer_personal_info['last_name']) TextElement(self.driver, locators.DOB_INPUT).set_text( customer_personal_info['date_of_birth']) BaseElement(self.driver, locators.NEXT_BUTTON).click() BaseElement(self.driver, locators.DISABLED_NEXT_BUTTON).wait_until_displayed() TextElement(self.driver, locators.SSN_INPUT).set_text(customer_personal_info['ssn']) BaseElement(self.driver, locators.NEXT_BUTTON).click() TextElement(self.driver, locators.PERMANENT_ADDRESS_INPUT).wait_until_displayed()
def open_buy_sell_modal(self): """ Open modal to buy or sell shares """ BaseElement(self.driver, locators.INVESTMENT_ORDER_BUY_SELL_BUTTON).click() BaseElement(self.driver, locators.INVESTMENT_ORDER_BUY_SELL_MODAL_HEADER ).wait_until_displayed()
def enter_pwif_amount(self, pwif_amount): """ Type a PWIF amount then submit the form""" TextElement(self.driver, locators.PWIF_OTHER_AMOUNT).set_text(pwif_amount) BaseElement(self.driver, locators.PWIF_NEXT_BUTTON).wait_until_displayed() BaseElement(self.driver, locators.PWIF_NEXT_BUTTON).click()
def get_save_balance(self): """ Return the displayed balance of the user's Aspiration Save Account """ BaseElement(self.driver, locators.SAVE_ACCOUNT_TEXT).wait_until_displayed() # Manually scrolling up is necessary because even seeing the label might still hide amount self.touch_scroll_up() element = BaseElement(self.driver, locators.SAVE_BALANCE_TEXT) return Decimal(re.sub(r'[^\d.]', '', element.get_text()))
def wait_until_dashboard_displayed(self): """ Wait until the dashboard page is displayed Because the emulator is slow logging in, we must allow a longer wait time """ BaseElement(self.driver, locators.PROFILE_IMAGE).wait_until_displayed(20) BaseElement(self.driver, locators.WELCOME_MESSAGE).wait_until_displayed(20) BaseElement(self.driver, locators.PRODUCT_BRICK).wait_until_displayed(20)
def close_previewed_transfer(self): """ Close transfer preview """ close_confirmation_button = BaseElement(self.driver, locators.RECEIPT_CLOSE_BUTTON) close_confirmation_button.click() BaseElement(self.driver, locators.RECEIPT_STATUS_TEXT).wait_until_not_displayed()
def cancel_previewed_transfer(self): """ cancel the previewed transfer """ BaseElement(self.driver, locators.RECEIPT_CANCEL_BUTTON).click() BaseElement(self.driver, locators.ALERT_YES_BUTTON).click() BaseElement(self.driver, locators.RECEIPT_STATUS_TEXT).wait_until_not_displayed() self.wait_until_transfers_displayed()
def submit_credentials_to_google(self, email): """ Open google modal and submit email to sign in through google """ TextElement(self.driver, locators.GOOGLE_EMAIL_OR_PHONE_INPUT).set_text(email) BaseElement(self.driver, locators.GOOGLE_SIGN_IN_NEXT_BUTTON).click() BaseElement(self.driver, locators.OKTA_USERNAME_INPUT).wait_until_displayed() BaseElement(self.driver, locators.OKTA_PASSWORD_INPUT).wait_until_displayed() BaseElement(self.driver, locators.OKTA_SIGN_IN_BUTTON).wait_until_displayed()
def wait_until_debit_card_tracker_displayed(self): """ Wait until the Debit Card Tracker is displayed """ self.wait_until_dashboard_displayed() tracker = BaseElement(self.driver, locators.DEBIT_CARD_TRACKER) # Sometimes the tracker doesn't display right away, added a refresh to cover this case if tracker.not_displayed(): self.driver.refresh() tracker.wait_until_displayed()
def wait_until_dashboard_displayed(self): """ Check whether the dashboard loads Return true if dashboard elements appear Return false if they do not """ BaseElement(self.driver, locators.DASHBOARD_HEADER).wait_until_displayed() BaseElement(self.driver, locators.DASHBOARD_FRAME).wait_until_displayed()
def get_to_google_login(self): """ Wait for admin screen to load, click google icon and wait for modal to display""" BaseElement(self.driver, locators.ADMIN_ICON).wait_until_displayed() BaseElement(self.driver, locators.GOOGLE_SIGN_IN_BUTTON).wait_until_displayed() BaseElement(self.driver, locators.GOOGLE_SIGN_IN_BUTTON).click() WindowElement(self.driver).wait_until_window_switched(locators.GOOGLE_EMAIL_OR_PHONE_INPUT) BaseElement(self.driver, locators.GOOGLE_EMAIL_OR_PHONE_INPUT).wait_until_displayed() BaseElement(self.driver, locators.GOOGLE_SIGN_IN_NEXT_BUTTON).wait_until_displayed()
def wait_until_navigation_displayed(self): """ Wait until the navigation page is displayed """ BaseElement(self.driver, locators.SUMMARY_BUTTON).wait_until_displayed() BaseElement(self.driver, locators.IMPACT_BUTTON).wait_until_displayed() BaseElement(self.driver, locators.SETTINGS_BUTTON).wait_until_displayed() BaseElement(self.driver, locators.MANAGE_BUTTON).wait_until_displayed()
def cancel_all_scheduled_transfers(self): """ Cancel all scheduled transfers """ self.show_scheduled_transfers() top_scheduled_row = BaseElement(self.driver, locators.FIRST_SCHEDULED_TRANSFER_LINK) while top_scheduled_row.displayed(3): self.open_next_scheduled_transfer() self.cancel_previewed_transfer()
def choose_pwif_amount(self, pwif_amount): """ Select a Pay What is Fair amount then submit the form """ if type(pwif_amount) is PWIFAmount: pwif_amount = pwif_amount.value pwif_amount_button = locators.pwif_amount_button(pwif_amount) BaseElement(self.driver, pwif_amount_button).click() BaseElement(self.driver, locators.PWIF_NEXT_BUTTON).wait_until_displayed() BaseElement(self.driver, locators.PWIF_NEXT_BUTTON).click()
def finish_purchase_order(self, submit=True): """ Submit or cancel purchase order """ if submit: BaseElement( self.driver, locators. INVESTMENT_ORDER_BUY_SELL_MODAL_PLACE_ORDER_BUTTON).click() else: BaseElement(self.driver, locators. INVESTMENT_ORDER_BUY_SELL_MODAL_CANCEL_BUTTON).click()
def finish_place_order(self, submit=True): """ Final place order or cancel purchase order """ if submit: BaseElement( self.driver, locators.INVESTMENT_PLACE_ORDER_PROCEED_BUTTON).click() else: BaseElement(self.driver, locators.INVESTMENT_PLACE_ORDER_CANCEL_BUTTON).click()
def review_and_confirm_deposit_details(self): """ Review the deposit and continues to Application Submission page Confirms the Application Submission step displays after confirmation """ BaseElement(self.driver, locators.REVIEW_YOUR_DEPOSIT_TITLE).wait_until_displayed() BaseElement(self.driver, locators.NEXT_BUTTON).click() BaseElement(self.driver, locators.SUBMIT_APPLICATION_BUTTON).wait_until_displayed()
def get_login_status(self): """ Return the status of Login page """ login_page_displayed = TextElement(self.driver, locators.EMAIL_INPUT).displayed(3) error_message = BaseElement(self.driver, locators.ERROR_MESSAGE) if not login_page_displayed: return LoginStatus.NOT_AT_LOGIN_PAGE elif error_message.displayed(3): return self.get_error_message_status() else: return LoginStatus.NO_MESSAGE_PROMPT
def get_opening_deposit_amount(self): """ Return the amount of the Opening Deposit transfer""" transfer_amount = BaseElement(self.driver, locators.FIRST_HISTORY_TRANSFER_AMOUNT) if transfer_amount.displayed(5): opening_deposit = utils.decimal_from_string( transfer_amount.get_text()) else: return None return opening_deposit
def wait_until_confirm_place_order_page_is_displayed(self): """ Wait until the place order confirmation page is displayed """ BaseElement( self.driver, locators.INVESTMENT_PLACE_ORDER_AMOUNT).wait_until_displayed() BaseElement(self.driver, locators.INVESTMENT_PLACE_ORDER_FUND_SYMBOL ).wait_until_displayed() BaseElement( self.driver, locators.INVESTMENT_PLACE_ORDER_FUND_NAME).wait_until_displayed()
def wait_until_transfers_displayed(self): """ Check whether the current page is the transfers page Dismiss any First-Visit tutorial hints """ BaseElement(self.driver, locators.HISTORY_TAB).wait_until_displayed() BaseElement(self.driver, locators.SCHEDULED_TAB).wait_until_displayed() first_time_alert = BaseElement(self.driver, locators.FIRST_TIME_ALERT_TEXT) if first_time_alert.displayed(0.5): BaseElement(self.driver, locators.FIRST_TIME_ALERT_TEXT).click() first_time_alert.wait_until_not_displayed()
def logout(self): """ Log out """ BaseElement(self.driver, locators.DRAWER_BUTTON).click() BaseElement(self.driver, locators.VIEW_SETTINGS_BUTTON).click() # QA-279 todo: Remove this wait + touch scrolling when the UiAutomator locator works again BaseElement(self.driver, locators.USERNAME_TEXT).wait_until_displayed() self.touch_scroll_up() BaseElement(self.driver, locators.LOGOUT_BUTTON).click() BaseElement(self.driver, locators.ALERT_YES_BUTTON).click()
def get_line_item_summary_details(self): """ Get summary from an investment purchase/sale line item """ summary_details = { "bank": BaseElement(self.driver, locators.INVESTMENT_ORDER_DESCRIPTION).get_text(), "amount": BaseElement(self.driver, locators.INVESTMENT_ORDER_AMOUNT).get_text() } return summary_details
def submit_plaid_account_numbers(self, routing_number, account_number): """ Submit new customer's Plaid routing number and account number """ IframeElement(self.driver, locators.PLAID_IFRAME).switch_to_iframe(start_at_default_content=True) TextElement(self.driver, locators.ROUTING_NUMBER_INPUT).set_text(routing_number) BaseElement(self.driver, locators.PLAID_LINK_ACCOUNT_CONTINUE_BUTTON).click() TextElement(self.driver, locators.ACCOUNT_NUMBER_INPUT).set_text(account_number) BaseElement(self.driver, locators.PLAID_LINK_ACCOUNT_CONTINUE_BUTTON).click() TextElement(self.driver, locators.ACCOUNT_NUMBER_INPUT).set_text(account_number) BaseElement(self.driver, locators.PLAID_LINK_ACCOUNT_CONTINUE_BUTTON).click() BaseElement(self.driver, locators.PLAID_SUCCESS_HEADER).wait_until_displayed() BaseElement(self.driver, locators.PLAID_LINK_ACCOUNT_CONTINUE_BUTTON).click() self.driver.switch_to.default_content()
def get_cancel_confirmation_details(self): """ get cancel confirmation details """ confirmation_details = { "amount": BaseElement(self.driver, locators.INVESTMENT_CANCEL_ORDER_AMOUNT).get_text(), "fund_symbol": BaseElement(self.driver, locators.INVESTMENT_CANCEL_ORDER_SYMBOL).get_text(), "fund_name": BaseElement(self.driver, locators.INVESTMENT_CANCEL_ORDER_FUND).get_text() } return confirmation_details
def get_error_message_status(self): """ Return Login error message """ used_email_partial_text = "already created" invalid_credentials_partial_text = "don’t recognize the email/password" locked_user_partial_text = "currently locked" error_message = BaseElement(self.driver, locators.ERROR_MESSAGE) if used_email_partial_text in error_message.get_text(): return LoginStatus.EMAIL_ALREADY_EXITS elif invalid_credentials_partial_text in error_message.get_text(): return LoginStatus.INVALID_CREDENTIALS elif locked_user_partial_text in error_message.get_text(): return LoginStatus.LOCKED_USER else: return LoginStatus.UNKNOWN_PROMPT