def go_back(self): Wait(self.marionette).until(expected.element_enabled(self.root_element) and expected.element_displayed(self.root_element)) self.marionette.switch_to_shadow_root(self.root_element) self.marionette.find_element(*self._back_button_locator).tap() self.marionette.switch_to_shadow_root() Wait(self.marionette).until(expected.element_not_displayed(self.root_element))
def tap_save_event(self): event_start_time = self.marionette.find_element(*self._event_start_time_value_locator).text event_start_date = self.marionette.find_element(*self._event_start_date_value_locator).text el = self.marionette.find_element(*self._modify_event_view_locator) self.marionette.find_element(*self._save_event_button_locator).tap() Wait(self.marionette).until(expected.element_not_displayed(el)) return datetime.strptime(event_start_time + event_start_date, '%I:%M %p%m/%d/%Y')
def confirm_turnon_options(self): self.marionette.switch_to_frame() close_btn = self.marionette.find_element(By.CSS_SELECTOR, 'button.value-option-confirm') close_btn.tap() Wait(self.marionette).until(expected.element_not_displayed(close_btn)) self.apps.switch_to_displayed_app() Wait(self.marionette).until(expected.element_displayed(*self._power_save_checkbox_locator))
def a11y_click_save_event(self): event_start_time = self.marionette.find_element(*self._event_start_time_value_locator).text event_start_date = self.marionette.find_element(*self._event_start_date_value_locator).text el = self.marionette.find_element(*self._modify_event_view_locator) self.accessibility.click(self.marionette.find_element(*self._save_event_button_locator)) Wait(self.marionette).until(expected.element_not_displayed(el)) return datetime.strptime(event_start_time + event_start_date, "%I:%M %p%m/%d/%Y")
def select(self, match_string): # This needs to be duplicated from base.py for a few reasons: # 1. When we return from the frame we don't return to the Settings app in its initial state, # so the wait for in its launch method times out # 2. We need to use in instead of == on the match text because of the directional strings # have to go back to top level to get the B2G select box wrapper self.marionette.switch_to_frame() options = Wait(self.marionette).until(expected.elements_present( By.CSS_SELECTOR, '.value-selector-container li')) close = self.marionette.find_element(By.CSS_SELECTOR, 'button.value-option-confirm') # loop options until we find the match for li in options: if match_string in li.text: self.marionette.execute_script('arguments[0].scrollIntoView(false);', [li]) li.tap() break else: raise Exception("Element '%s' could not be found in select wrapper" % match_string) close.tap() Wait(self.marionette).until(expected.element_not_displayed(close)) # TODO we should find something suitable to wait for, but this goes too # fast against desktop builds causing intermittent failures time.sleep(0.2) # now back to app self.apps.switch_to_displayed_app()
def tap_settings(self): settings = self.marionette.find_element(*self._settings_button_locator) Wait(self.marionette).until(expected.element_displayed(settings)) settings.tap() Wait(self.marionette).until(expected.element_not_displayed(settings)) from gaiatest.apps.contacts.regions.settings_form import SettingsForm return SettingsForm(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 tap_done(self): time_picker = self.marionette.find_element(*self._time_picker_locator) self.marionette.find_element(*self._done_button_locator).tap() Wait(self.marionette).until(expected.element_not_displayed(time_picker)) # TODO: wait for the time picker to fade out Bug 1038186 time.sleep(2) self.apps.switch_to_displayed_app()
def tap_lets_go(self): self.marionette.find_element(*self._go_button_locator).tap() Wait(self.marionette).until(expected.element_not_displayed(*self._ftu_frame_locator)) self.apps.switch_to_displayed_app() # TODO Some wait for Usage to fully initialize time.sleep(2)
def tap_back_button(self): element = Wait(self.marionette).until( expected.element_present(*self._test_panel_header_locator)) Wait(self.marionette).until(expected.element_displayed(element)) # TODO: remove tap with coordinates after Bug 1061698 is fixed element.tap(25, 25) Wait(self.marionette).until(expected.element_not_displayed(element))
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 cancel_get_more_home_screen(self): self.marionette.find_element(*self._pick_cancel_button_locator).tap() Wait(self.marionette).until(expected.element_not_displayed(*self._pick_cancel_button_locator)) self.apps.switch_to_displayed_app() element = Wait(self.marionette).until( expected.element_present(*self._change_homescreen_page_locator)) Wait(self.marionette).until(expected.element_displayed(element))
def select(self, match_string): # This needs to be duplicated from base.py because when we return from the frame # we don't return to the Settings app in its initial state, # so the wait for in its launch method times out # have to go back to top level to get the B2G select box wrapper self.marionette.switch_to_frame() Wait(self.marionette).until( expected.elements_present( By.CSS_SELECTOR, '.value-selector-container li')) options = self.marionette.find_elements(By.CSS_SELECTOR, '.value-selector-container li') close = self.marionette.find_element(By.CSS_SELECTOR, 'button.value-option-confirm') # loop options until we find the match for li in options: if match_string == li.text: li.tap() break else: raise Exception("Element '%s' could not be found in select wrapper" % match_string) close.tap() Wait(self.marionette).until(expected.element_not_displayed(close)) # TODO we should find something suitable to wait for, but this goes too # fast against desktop builds causing intermittent failures time.sleep(0.2) # now back to app self.apps.switch_to_displayed_app()
def tap_tile_view_button(self): fullscreen = self.marionette.find_element(*self._fullscreen_view_locator) self.marionette.find_element(*self._tile_view_locator).tap() Wait(self.marionette).until(expected.element_not_displayed(fullscreen)) from gaiatest.apps.gallery.app import Gallery return Gallery(self.marionette)
def __init__(self, marionette): Base.__init__(self, marionette) Wait(self.marionette).until(lambda m: self.apps.displayed_app.src == self._src) self.apps.switch_to_displayed_app() loading = self.marionette.find_element(*self._collection_loading_locator) Wait(self.marionette).until(expected.element_displayed(loading)) # See Bug 1162112, Marionette Wait() polling without interval might be interfering network load Wait(self.marionette, timeout=30, interval=5).until(expected.element_not_displayed(loading))
def tap_edit(self): edit = Wait(self.marionette).until(expected.element_present( *self._edit_contact_button_locator)) Wait(self.marionette).until(expected.element_displayed(edit)) edit.tap() Wait(self.marionette).until(expected.element_not_displayed(edit)) from gaiatest.apps.contacts.regions.contact_form import EditContact return EditContact(self.marionette)
def cancel_pick_wallpaper(self): self.marionette.switch_to_frame() self.marionette.find_element(*self._pick_cancel_button_locator).tap() Wait(self.marionette).until(expected.element_not_displayed(*self._pick_cancel_button_locator)) self.apps.switch_to_displayed_app() element = Wait(self.marionette).until( expected.element_present(*self._wallpaper_preview_locator)) Wait(self.marionette).until(expected.element_displayed(element))
def tap_back(self): el = self.marionette.find_element(*self._details_header_locator) Wait(self.marionette).until(expected.element_displayed(el)) # TODO: remove tap with coordinates after Bug 1061698 is fixed el.tap(25, 25) Wait(self.marionette).until(expected.element_not_displayed(el)) from gaiatest.apps.contacts.app import Contacts return Contacts(self.marionette)
def tap_save_event(self): date_str = self.marionette.find_element(*self._event_start_date_value_locator).get_attribute("data-date") el = self.marionette.find_element(*self._modify_event_view_locator) self.marionette.find_element(*self._save_event_button_locator).tap() Wait(self.marionette).until(expected.element_not_displayed(el)) date_list = date_str.split() return date_list[1] + " " + date_list[2]
def tap_cancel(self): actions_menu = Wait(self.marionette).until( expected.element_present(*self._actions_menu_locator)) Wait(self.marionette).until( expected.element_displayed(actions_menu)) self.marionette.find_element(*self._cancel_button_locator).tap() Wait(self.marionette).until( expected.element_not_displayed(actions_menu)) self.apps.switch_to_displayed_app()
def tap_switch_to_camera(self): self.marionette.find_element(*self._camera_locator).tap() from gaiatest.apps.camera.app import Camera camera_app = Camera(self.marionette) camera_app.wait_to_be_displayed() self.apps.switch_to_displayed_app() camera_app.wait_for_capture_ready() Wait(self.marionette).until(expected.element_not_displayed(*self._loading_screen_locator)) return camera_app
def take_photo(self): self.wait_for_capture_ready() self.tap_capture() # Wait for thumbnail to appear self.wait_for_thumbnail_visible() Wait(self.marionette).until( expected.element_not_displayed(*self._loading_screen_locator))
def tap_edit_save_button(self): element = Wait(self.marionette).until( expected.element_present(*self._edit_save_locator)) Wait(self.marionette).until(expected.element_displayed(element)) element.tap() progress = self.marionette.find_element(*self._save_progress_bar_locator) Wait(self.marionette).until(expected.element_not_displayed(progress)) from gaiatest.apps.gallery.app import Gallery return Gallery(self.marionette)
def tap_edit_save_button(self): element = Wait(self.marionette).until( expected.element_present(*self._edit_save_locator)) Wait(self.marionette).until(expected.element_displayed(element)) element.tap() progress = self.marionette.find_element(*self._save_progress_bar_locator) Wait(self.marionette).until(expected.element_not_displayed(progress)) from gaiatest.apps.gallery.regions.fullscreen_image import FullscreenImage return FullscreenImage(self.marionette)
def tap_first_friend(self): element = self.marionette.find_element(*self._friends_list_locator) # TODO replace this with proper tap when Bug 932804 is resolved self.marionette.execute_script(""" window.wrappedJSObject.document.getElementById("friends-list") .getElementsByTagName("a")[1].click() """) Wait(self.marionette).until(expected.element_not_displayed(element)) self.apps.switch_to_displayed_app()
def share_to_ringtones(self): actions_menu = Wait(self.marionette).until( expected.element_present(*self._actions_menu_locator)) Wait(self.marionette).until( expected.element_displayed(actions_menu)) self.marionette.find_element(*self._ringtones_button_locator).tap() Wait(self.marionette).until( expected.element_not_displayed(actions_menu)) from gaiatest.apps.ring_tone.app import RingTone return RingTone(self.marionette)
def tap_import_button(self, wait_for_import = True): self.marionette.execute_script('window.wrappedJSObject.importer.ui.importAll();') # TODO uncomment this when Bug 932804 is resolved # self.marionette.find_element(*self._import_button_locator).tap() self.apps.switch_to_displayed_app() if wait_for_import: Wait(self.marionette, timeout=60).until( expected.element_not_displayed(*self._contact_import_picker_frame_locator)) from gaiatest.apps.contacts.regions.settings_form import SettingsForm return SettingsForm(self.marionette)
def share_to_messages(self): actions_menu = Wait(self.marionette).until( expected.element_present(*self._actions_menu_locator)) Wait(self.marionette).until( expected.element_displayed(actions_menu)) self.marionette.find_element(*self._messages_button_locator).tap() Wait(self.marionette).until( expected.element_not_displayed(actions_menu)) from gaiatest.apps.messages.regions.new_message import NewMessage return NewMessage(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 wait_for_select_closed(self, by, locator): Wait(self.marionette).until(expected.element_not_displayed(by, locator)) # now back to app self.apps.switch_to_displayed_app() # TODO we should find something suitable to wait for, but this goes too # fast against desktop builds causing intermittent failures # This sleep is necessary to make sure the select is completely faded out, # see bug 1148154 time.sleep(1)
def a11y_keypad_hang_up(self): self.a11y_click_keypad_hang_up() self.marionette.switch_to_frame() Wait(self.marionette).until( expected.element_not_displayed(*self._call_screen_locator))
def dismiss_banner(self): banner = Wait(self.marionette).until( expected.element_present(*self._banner_countdown_notification_locator)) Wait(self.marionette).until(expected.element_displayed(banner)) # We can't tap to clear the banner as sometimes it taps the underlying alarm changing the UI Wait(self.marionette).until(expected.element_not_displayed(banner))
def test_element_not_displayed_when_stale_element(self): self.marionette.navigate(static_element) el = self.marionette.find_element(By.TAG_NAME, "p") self.marionette.navigate("about:blank") missing = expected.element_not_displayed(el)(self.marionette) self.assertTrue(missing)
def test_element_not_displayed_locator(self): self.marionette.navigate(hidden_element) hidden = expected.element_not_displayed(By.TAG_NAME, "p")(self.marionette) self.assertTrue(hidden)
def a11y_click_done(self, return_contacts=True): element = self.marionette.find_element(*self._done_button_locator) self.accessibility.click(element) Wait(self.marionette).until(expected.element_not_displayed(element)) return self.wait_for_done(return_contacts)
def tap_confirm_deletion_button(self): element = self.marionette.find_element(*self._confirm_delete_locator) element.tap() Wait(self.marionette).until(expected.element_not_displayed(element))
def tap_done(self): close = self.marionette.find_element(*self._settings_close_button_locator) close.tap() Wait(self.marionette).until(expected.element_not_displayed(close)) from gaiatest.apps.contacts.app import Contacts return Contacts(self.marionette)
def wait_for_resizing_to_finish(self): Wait(self.marionette).until( expected.element_not_displayed(*self._message_resize_notice_locator))
def wait_for_element_not_displayed(self, by, locator): Wait(self.marionette).until( expected.element_not_displayed( Wait(self.marionette).until( expected.element_present(by, locator))))
def __init__(self, marionette): Phone.__init__(self, marionette) Wait(self.marionette).until( expected.element_not_displayed(*self._upgrade_progress_locator)) Wait(self.marionette).until( expected.element_displayed(*self._all_calls_tab_link_locator))
def confirm_eject(self): self.marionette.find_element(*self._eject_dialog_confirm_locator).tap() Wait(self.marionette).until( expected.element_not_displayed( *self._eject_dialog_confirm_locator))
def wait_for_notification_toaster_not_displayed(self, timeout=10): self.marionette.switch_to_frame() Wait(self.marionette, timeout).until( expected.element_not_displayed( *self._notification_toaster_locator))
def wait_for_system_banner_not_displayed(self): self.marionette.switch_to_frame() Wait(self.marionette).until( expected.element_not_displayed(*self._system_banner_locator))
def tap_update_device_name_ok(self): element = self.marionette.find_element( *self._update_device_name_ok_locator) element.tap() Wait(self.marionette).until(expected.element_not_displayed(element))
def tap_forget_wifi(self): element_to_forget = Wait(self.marionette).until(expected.element_present(*self._forget_locator)) Wait(self.marionette).until(expected.element_displayed(element_to_forget)) element_to_forget.tap() Wait(self.marionette).until(expected.element_not_displayed(element_to_forget))
def tap_back_from_import_contacts(self): header = self.marionette.find_element(*self._import_settings_header) # TODO: remove tap with coordinates after Bug 1061698 is fixed header.tap(25, 25) Wait(self.marionette).until(expected.element_not_displayed(header))
def wait_for_cards_view_not_displayed(self): Wait(self.marionette).until( expected.element_not_displayed(self.root_element))
def wait_for_banner_to_hide(self): Wait(self.marionette).until(expected.element_not_displayed(*self._banner_locator))
def confirm_delete_message(self): confirm_delete_message = self.marionette.find_element(*self._confirm_delete_message_locator) Wait(self.marionette).until(expected.element_displayed(confirm_delete_message)) confirm_delete_message.tap() Wait(self.marionette).until(expected.element_not_displayed(confirm_delete_message))
def launch(self): Base.launch(self) Wait(self.marionette).until( expected.element_not_displayed(*self._loading_spinner_locator))
def test_element_not_displayed(self): self.marionette.navigate(hidden_element) el = self.marionette.find_element(By.TAG_NAME, "p") hidden = expected.element_not_displayed(el)(self.marionette) self.assertTrue(hidden)
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(*self._section_wifi_locator))
def test_element_not_displayed_when_visible_locator(self): self.marionette.navigate(static_element) hidden = expected.element_not_displayed(By.TAG_NAME, "p")(self.marionette) self.assertFalse(hidden)
def a11y_click_next_to_wifi_section(self): self.a11y_click_next() Wait(self.marionette).until( expected.element_not_displayed(*self._loading_overlay_locator)) Wait(self.marionette).until( expected.element_displayed(*self._section_wifi_locator))
def wait_for_cards_view_not_displayed(self): Wait(self.marionette).until( expected.element_not_displayed(*self._cards_view_locator))
def remove(self): frequency = self.marionette.find_element(*self._frequency_locator) self.root_element.find_element(*self._remove_locator).tap() Wait(self.marionette).until( expected.element_not_displayed(frequency))
def go_back(self): element = self.marionette.find_element(*self._go_back_locator) element.tap() Wait(self.marionette).until(expected.element_not_displayed(element)) from gaiatest.apps.gallery.app import Gallery return Gallery(self.marionette)
def wait_for_loading_spinner_hidden(self): loading_spinner = self.marionette.find_element(*self._loading_screen_locator) Wait(self.marionette).until(expected.element_not_displayed(loading_spinner))
def a11y_wheel_utility_tray_grippy(self): self.accessibility.wheel( self.marionette.find_element(*self._grippy_locator), 'up') Wait(self.marionette).until( expected.element_not_displayed( *System(self.marionette)._utility_tray_locator))
def wait_for_software_home_button_not_displayed(self, timeout=10): self.marionette.switch_to_frame() Wait(self.marionette, timeout=timeout).until( expected.element_not_displayed( *self._software_home_button_locator))