def _switch_to_correct_layout(self, val): if val.isspace() or val in [',', '.']: # certain keys are available on every keyboard panel pass # Alphabetic keys available on the basic page elif val.isalpha(): is_upper_case = self._is_upper_case # If the key to press isalpha and the keyboard layout is not, go back to Basic if not self._layout_page == 0: self._tap_page_switching_key(0) Wait(self.marionette).until(lambda m: self._layout_page == 0) # If the key to press isupper and the keyboard is not (or vice versa) then press shift if not val.isupper() == is_upper_case: self._tap(self._upper_case_key) Wait(self.marionette).until(lambda m: is_upper_case != self._is_upper_case) # Numbers and symbols are in other keyboard panels else: # If it's not space or alpha then it must be in Alternate or Symbol. # It can't be in Basic so let's go into Alternate and then try to find it if self._layout_page == 0 and not self._current_input_type == 'number' and not self._current_input_mode == 'numeric': self._tap_page_switching_key(1) page_0_key_locator = (self._page_switching_key_locator[0], self._page_switching_key_locator[1] % (0)) Wait(self.marionette).until(expected.element_displayed(*page_0_key_locator)) # If it is not present here then it must be in the other non-Basic page # (since we must be in either Alternate or Symbol at this stage) if not self.is_element_present(*self._key_locator(val)): if self._layout_page == 1: self._tap_page_switching_key(2) page_1_key_locator = (self._page_switching_key_locator[0], self._page_switching_key_locator[1] % (1)) Wait(self.marionette).until(expected.element_displayed(*page_1_key_locator)) else: self._tap_page_switching_key(1) page_2_key_locator = (self._page_switching_key_locator[0], self._page_switching_key_locator[1] % (2)) Wait(self.marionette).until(expected.element_displayed(*page_2_key_locator))
def launch(self): Base.launch(self) Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._visible_clock_locator)))) Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._alarm_create_new_locator))))
def a11y_click_month_display_button(self): self.accessibility.click(self.marionette.find_element(*self._month_display_button_locator)) Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._current_monthly_calendar_locator)))) Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._current_month_day_agenda_locator))))
def tap_unlink_contact(self): facebook_unlink_button = Wait(self.marionette).until(expected.element_present(*self._facebook_link_locator)) Wait(self.marionette).until(expected.element_displayed(facebook_unlink_button)) facebook_unlink_button.tap() facebook_confirm_unlink_button = Wait(self.marionette).until(expected.element_present(*self._confirm_unlink_button_locator)) Wait(self.marionette).until(expected.element_displayed(facebook_confirm_unlink_button)) facebook_confirm_unlink_button.tap() self.apps.switch_to_displayed_app()
def unlock_to_passcode_pad(self): Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._lockscreen_handle_locator)))) self._slide_to_unlock('homescreen') Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._lockscreen_passcode_code_locator)))) return PasscodePad(self.marionette)
def tap_import_from_sim(self): import_from_sim = Wait(self.marionette).until( expected.element_present(*self._import_from_sim_button_locator)) Wait(self.marionette).until(expected.element_displayed(import_from_sim)) import_from_sim.tap() from gaiatest.apps.contacts.app import Contacts status_message = Wait(self.marionette).until( expected.element_present(*Contacts._status_message_locator)) Wait(self.marionette).until(expected.element_displayed(status_message)) Wait(self.marionette).until(expected.element_not_displayed(status_message))
def __init__(self, marionette): Base.__init__(self, marionette) # go into iframe of usage app settings frame = Wait(self.marionette).until(expected.element_present( *self._settings_iframe_locator)) Wait(self.marionette).until(expected.element_displayed(frame)) self.marionette.switch_to_frame(frame) Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._settings_title_locator))))
def create_passcode(self, passcode): # switch to keyboard, input passcode for times in range(2): self.keyboard.send("".join(passcode)) # Back to create passcode Wait(self.marionette).until(expected.element_displayed( *self._screen_lock_passcode_section_locator)) self.marionette.find_element(*self._passcode_create_locator).tap() Wait(self.marionette).until(expected.element_displayed( *self._screen_lock_section_locator))
def search(self, term): iframe = Wait(self.marionette).until( expected.element_present(*self._marketplace_iframe_locator)) Wait(self.marionette).until(expected.element_displayed(iframe)) self.marionette.switch_to_frame(iframe) search_box = Wait(self.marionette).until( expected.element_present(*self._search_locator)) Wait(self.marionette).until(expected.element_displayed(search_box)) # search for the app search_box.send_keys(term) search_box.send_keys(Keys.RETURN) return SearchResults(self.marionette)
def reset_mobile_usage(self): self.marionette.find_element(*self._reset_button_locator).tap() reset_mobile_usage = Wait(self.marionette).until( expected.element_present(*self._reset_mobile_usage_button_locator)) Wait(self.marionette).until(expected.element_displayed(reset_mobile_usage)) reset_dialog = self.marionette.find_element(*self._reset_dialog_locator) reset_mobile_usage.tap() confirm_reset_button = Wait(self.marionette).until( expected.element_present(*self._confirm_reset_button_locator)) Wait(self.marionette).until(expected.element_displayed(confirm_reset_button)) confirm_reset_button.tap() Wait(self.marionette).until(expected.element_not_displayed(reset_dialog))
def tap_delete_button(self, confirm=True): delete_button = Wait(self.marionette).until( expected.element_present(*self._delete_thumbnail_locator)) Wait(self.marionette).until(expected.element_displayed(delete_button)) delete_button.tap() if confirm: confirm_decision_button = Wait(self.marionette).until( expected.element_present(*self._delete_confirm_locator)) else: confirm_decision_button = Wait(self.marionette).until( expected.element_present(*self._delete_cancel_locator)) Wait(self.marionette).until(expected.element_displayed(confirm_decision_button)) confirm_decision_button.tap()
def reject_call(self): Wait(self.marionette).until( expected.element_displayed(*self._lockscreen_handle_locator)) self._handle_incoming_call('reject') self.marionette.switch_to_frame() Wait(self.marionette).until( expected.element_not_displayed(*self._call_screen_locator))
def tap_first_predictive_word(self): self.switch_to_keyboard() key = Wait(self.marionette).until( expected.element_present(*self._predicted_word_locator)) Wait(self.marionette).until(expected.element_displayed(key)) key.tap() self.apps.switch_to_displayed_app()
def tap_next_to_geolocation_section(self): self.tap_next() Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until( expected.element_present( *self._section_geolocation_locator))))
def tap_import_from_gmail(self): import_from_gmail = Wait(self.marionette).until( expected.element_present(*self._import_from_gmail_button_locator)) Wait(self.marionette).until(expected.element_displayed(import_from_gmail)) import_from_gmail.tap() from gaiatest.apps.contacts.regions.gmail import GmailLogin return GmailLogin(self.marionette)
def tap_export_to_sim(self): export_to_sim = Wait(self.marionette).until( expected.element_present(*self._export_to_sim_button_locator)) Wait(self.marionette).until(expected.element_displayed(export_to_sim)) export_to_sim.tap() select_contacts = self.marionette.find_element(*self._select_contacts_locator) Wait(self.marionette).until(lambda m: select_contacts.location['y'] == 0)
def launch(self): Base.launch(self) Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until( expected.element_present( *self._section_languages_locator))))
def a11y_click_next_to_privacy_browser_section(self): self.a11y_click_next() Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until( expected.element_present( *self._section_browser_privacy_locator))))
def tap_next_to_welcome_browser_section(self): self.tap_next() Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until( expected.element_present( *self._section_welcome_browser_locator))))
def a11y_click_next_to_firefox_accounts_section(self): self.a11y_click_next() Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until( expected.element_present( *self._section_firefox_accounts_locator))))
def a11y_click_next_to_import_contacts_section(self): self.a11y_click_next() Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until( expected.element_present( *self._section_import_contacts_locator))))
def disable_geolocation(self): element = Wait(self.marionette).until( expected.element_present( *self._enable_geolocation_checkbox_locator)) Wait(self.marionette).until(expected.element_displayed(element)) # TODO: Remove y parameter when Bug 932804 is fixed element.tap(y=30)
def __init__(self, marionette): Base.__init__(self, marionette) Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._contact_import_picker_frame_locator)))) select_contacts = self.marionette.find_element(*self._contact_import_picker_frame_locator) self.marionette.switch_to_frame(select_contacts)
def tap_delete_button(self): self.marionette.find_element(*self._delete_image_locator).tap() Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until(expected.element_present(*self._confirm_delete_locator)) ) )
def tap_share_button(self): share_button = Wait(self.marionette).until( expected.element_present(*self._share_thumbnail_locator)) Wait(self.marionette).until(expected.element_displayed(share_button)) share_button.tap() from gaiatest.apps.system.regions.activities import Activities return Activities(self.marionette)
def tap_delete_contacts(self): delete_contacts = Wait(self.marionette).until( expected.element_present(*self._delete_contacts_locator)) Wait(self.marionette).until(expected.element_displayed(delete_contacts)) delete_contacts.tap() select_contacts = self.marionette.find_element(*self._select_contacts_locator) Wait(self.marionette).until(lambda m: select_contacts.location['y'] == 0)
def launch(self): Base.launch(self) Wait(self.marionette, ignored_exceptions=JavascriptException).until( lambda m: m.execute_script('return window.wrappedJSObject.Contacts.asyncScriptsLoaded;') is True) Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._settings_button_locator))))
def __init__(self, marionette): Base.__init__(self, marionette) Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until( expected.element_present(*self._24h_selector_locator))))
def a11y_click_edit(self): edit = Wait(self.marionette).until(expected.element_present( *self._edit_contact_button_locator)) Wait(self.marionette).until(expected.element_displayed(edit)) self.accessibility.click(edit) from gaiatest.apps.contacts.regions.contact_form import EditContact return EditContact(self.marionette)
def a11y_first_predictive_word_click(self): self.switch_to_keyboard() element = Wait(self.marionette).until( expected.element_present(*self._predicted_word_locator)) Wait(self.marionette).until(expected.element_displayed(element)) self.accessibility.click(element) self.apps.switch_to_displayed_app()
def send(self, string): self.switch_to_keyboard() for val in string: if ord(val) > 127: # this would get the right key to long press and switch to the right keyboard middle_key_val = self._find_key_for_longpress( val.encode('UTF-8')) self._switch_to_correct_layout(middle_key_val) # find the key to long press and press it to get the extended characters list middle_key = self.marionette.find_element( *self._key_locator(middle_key_val)) action = Actions(self.marionette) action.press(middle_key).wait(1).perform() # find the targeted extended key to send key = Wait(self.marionette).until( expected.element_present(*self._key_locator(val))) Wait(self.marionette).until(expected.element_displayed(key)) action.move(key).release().perform() else: # after switching to correct keyboard, tap/click if the key is there self._switch_to_correct_layout(val) self._tap(val) # when we tap on '@' the layout switches to the default keyboard - Bug 996332 if val == '@': Wait(self.marionette).until( lambda m: self._layout_page == 0) self.apps.switch_to_displayed_app()
def delete_file(self): self.tap_options() self.marionette.find_element(*self._delete_button_locator).tap() element = Wait(self.marionette).until( expected.element_present(*self._confirm_delete_button)) Wait(self.marionette).until(expected.element_displayed(element)) element.tap()
def tap_done(self): done_button = Wait(self.marionette).until( expected.element_present(*self._done_button_locator)) Wait(self.marionette).until(expected.element_displayed(done_button)) done_button.tap() # Switch back to Cost Control app frame self.apps.switch_to_displayed_app()
def launch(self): Base.launch(self) # empty message is only displayed after first MonthsDay#render, # so we are sure app is "ready" after that Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._event_list_empty_locator))))
def wait_for_enable_switch_to_be_turned_on(self): findmydevice = Wait(self.marionette, timeout=60).until( expected.element_present(*self._findmydevice_locator)) Wait(self.marionette).until(expected.element_displayed(findmydevice)) checkbox = Wait(self.marionette, timeout=60).until( expected.element_present(*self._checkbox_locator)) Wait(self.marionette).until(expected.element_selected(checkbox))
def tap_done(self): done = Wait(self.marionette, timeout=60).until( expected.element_present(*self._done_locator)) Wait(self.marionette).until(expected.element_displayed(done)) done.tap() #Switch back to the settings app self.apps.switch_to_displayed_app()
def __init__(self, marionette): Base.__init__(self, marionette) # <canvas> is dynamically inserted Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until( expected.element_present(*self._canvas_locator))))
def __init__(self, marionette): Base.__init__(self, marionette) Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until(expected.element_present(*self._current_image_locator)) ) )
def tap_portrait_crop(self): element = Wait(self.marionette).until( expected.element_present(*self._crop_portrait_locator)) Wait(self.marionette).until(expected.element_displayed(element)) element.tap() Wait(self.marionette).until( lambda m: 'selected' in element.get_attribute('class'))
def a11y_click_next_to_wifi_section(self): progress = self.marionette.find_element(*self._progress_activity_locator) self.a11y_click_next() Wait(self.marionette).until(expected.element_not_displayed(progress)) Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._section_wifi_locator))))
def tap_export_contacts(self): export_contacts = Wait(self.marionette).until( expected.element_present(*self._export_contacts_locator)) Wait(self.marionette).until(expected.element_displayed(export_contacts)) export_contacts.tap() import_settings = self.marionette.find_element(*self._import_settings_locator) Wait(self.marionette).until(lambda m: import_settings.location['x'] == 0)
def tap_share_to_messages(self): element = Wait(self.marionette).until( expected.element_present(*self._share_to_messages_button_locator)) Wait(self.marionette).until(expected.element_displayed(element)) element.tap() from gaiatest.apps.messages.regions.new_message import NewMessage return NewMessage(self.marionette)
def find_wifi_network(self, network_ssid): wifi_network_locator = (By.CSS_SELECTOR, '#networks-list li[data-ssid="%s"]' % network_ssid) wifi_network = Wait(self.marionette).until( expected.element_present(*wifi_network_locator)) self.marionette.execute_script("arguments[0].scrollIntoView(false);", [wifi_network]) Wait(self.marionette).until(expected.element_displayed(wifi_network)) return wifi_network
def __init__(self, marionette): Base.__init__(self, marionette) self.marionette.switch_to_frame() Wait(self.marionette).until(expected.element_displayed(*self._hour_picker_locator)) # TODO: wait for the time picker to fade in Bug 1038186 time.sleep(2)
def tap_keyboard_language_key(self): self.switch_to_keyboard() key = Wait(self.marionette).until( expected.element_present(*self._language_key_locator)) Wait(self.marionette).until(expected.element_displayed(key)) key.tap() self.apps.switch_to_displayed_app()
def __init__(self, marionette): Base.__init__(self, marionette) Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until( expected.element_present( *self._messaging_settings_locator))))
def a11y_click_next_to_timezone_section(self): self.a11y_click_next() Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until( expected.element_present( *self._section_date_time_locator))))
def __init__(self, marionette): Base.__init__(self, marionette) Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._crop_view_locator)))) done = self.marionette.find_element(*self._crop_done_button_locator) Wait(self.marionette).until(expected.element_enabled(done))
def tap_settings(self): settings = Wait(self.marionette).until( expected.element_present(*self._settings_button_locator)) Wait(self.marionette).until(expected.element_displayed(settings)) settings.tap() from gaiatest.apps.cost_control.regions.settings import Settings return Settings(self.marionette)
def tap_next_to_wifi_section(self): progress = self.marionette.find_element(*self._loading_overlay_locator) self.tap_next() Wait(self.marionette).until(expected.element_not_displayed(progress)) Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._section_wifi_locator))))
def __init__(self, marionette): Base.__init__(self, marionette) Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._actions_menu_locator)))) # TODO Difficult intermittent bug 977052 time.sleep(1)
def a11y_click_day_display_button(self): self.accessibility.click( self.marionette.find_element(*self._day_display_button_locator)) Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until( expected.element_present(*self._day_view_locator))))
def tap_new_alarm(self): new_alarm = Wait(self.marionette).until( expected.element_present(*self._alarm_create_new_locator)) Wait(self.marionette).until(expected.element_displayed(new_alarm)) new_alarm.tap() from gaiatest.apps.clock.regions.alarm import NewAlarm return NewAlarm(self.marionette)
def tap_add_collection(self): add_collection = Wait(self.marionette).until( expected.element_present(*self._add_collection_button_locator)) Wait(self.marionette).until(expected.element_displayed(add_collection)) add_collection.tap() from gaiatest.apps.homescreen.regions.collections_activity import CollectionsActivity return CollectionsActivity(self.marionette)
def __init__(self, marionette): Base.__init__(self, marionette) self.marionette.switch_to_frame() Wait(self.marionette).until( expected.element_displayed(*self._hour_picker_locator)) # TODO: wait for the time picker to fade in Bug 1038186 time.sleep(2)
def tap_next_to_wifi_section(self): progress = self.marionette.find_element(*self._loading_overlay_locator) self.tap_next() Wait(self.marionette).until(expected.element_not_displayed(progress)) Wait(self.marionette).until( expected.element_displayed( Wait(self.marionette).until( expected.element_present(*self._section_wifi_locator))))