def _toggle_and_verify_state(self, final_state): Wait(self.marionette).until(expected.element_enabled( self.root_element)) Wait(self.marionette).until( lambda m: self.is_checked is not final_state) self._toggle() Wait(self.marionette).until(lambda m: self.is_checked is final_state) Wait(self.marionette).until(expected.element_enabled( self.root_element))
def tap_fixed_dialing(self): element = self.marionette.find_element(*self._fixed_dialing_numbers_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until(expected.element_displayed( *self._fixed_dialing_page_locator))
def confirm_apn_selection(self): element = self.marionette.find_element(*self._apn_selector_confirm_button_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() self.apps.switch_to_displayed_app() Wait(self.marionette).until(expected.element_displayed(*self._apn_editor_page_locator))
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 open_time_format(self): self.marionette.find_element(*self._24h_selector_locator).tap() self.marionette.switch_to_frame() Wait(self.marionette).until( expected.element_enabled( self.marionette.find_element( *self._time_format_confirm_button_locator)))
def tap_manage_tones_selector(self): self.marionette.find_element(*self._manage_tones_selector_locator).tap() manage_tones_page = RingTone(self.marionette) element = self.marionette.find_element(*self._dulco_ringtone_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) return manage_tones_page
def enable_roaming(self): element = Wait(self.marionette).until( expected.element_present(*self._data_roaming_enabled_label_locator)) Wait(self.marionette).until(expected.element_displayed(element)) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() return self.data_prompt
def tap_alerts_selector(self): self.marionette.find_element(*self._alert_selector_locator).tap() alerts_page = RingTone(self.marionette) element = self.marionette.find_element(*self._firefox_alerts_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) return alerts_page
def tap_auth_numbers(self): element = self.marionette.find_element(*self._auth_number_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until(expected.element_displayed( *self._auth_number_page_locator))
def tap_call_forwarding(self): element = self.marionette.find_element(*self._call_forwarding_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until(expected.element_displayed( *self._call_forwarding_page_locator))
def confirm_network_type(self): element = self.marionette.find_element(*self._network_type_confirm_button_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() self.apps.switch_to_displayed_app() Wait(self.marionette).until(expected.element_displayed(*self._network_type_selector_locator))
def tap_call_button(self, switch_to_call_screen=True): element = Wait(self.marionette).until( expected.element_present(*self._call_bar_locator)) Wait(self.marionette).until(expected.element_enabled(element)) element.tap() if switch_to_call_screen: return CallScreen(self.marionette)
def tap_phone_number(self): call = self.marionette.find_element( *self._call_phone_number_button_locator) Wait(self.marionette).until(expected.element_enabled(call)) call.tap() from gaiatest.apps.phone.regions.call_screen import CallScreen return CallScreen(self.marionette)
def tap_sim_1(self): element = self.marionette.find_element(*self._sim_1_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until(expected.element_displayed( *self._call_settings_page_locator))
def select_roaming_protocol(self): element = self.marionette.find_element(*self._roaming_protocol_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() self.marionette.switch_to_frame() Wait(self.marionette).until(expected.element_displayed( *self._apn_selector_confirm_button_locator))
def tap_call_barring_all(self): element = self.marionette.find_element(*self._call_barring_all_switch_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until(expected.element_displayed(*self._call_barring_all_cancel_button_locator)) self.marionette.switch_to_frame() Wait(self.marionette).until(lambda m: self.keyboard.is_keyboard_displayed) self.apps.switch_to_displayed_app()
def tap_apn_settings(self): element = self.marionette.find_element(*self._apn_settings_locator) Wait(self.marionette).until( expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until( expected.element_displayed(*self._reset_apn_btn_locator))
def tap_send(self, timeout=120): send = Wait(self.marionette).until( expected.element_present(*self._send_message_button_locator)) Wait(self.marionette).until(expected.element_enabled(send)) send.tap() self.wait_for_element_not_present(*self._message_sending_locator, timeout=timeout) from gaiatest.apps.messages.regions.message_thread import MessageThread return MessageThread(self.marionette)
def tap_change_passcode(self): element = self.marionette.find_element(*self._change_passcode_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until(expected.element_displayed(*self._passcode_page_locator)) self.marionette.switch_to_frame() Wait(self.marionette).until(lambda m: self.keyboard.is_keyboard_displayed) self.apps.switch_to_displayed_app()
def tap_add_new_apn(self): element = self.marionette.find_element(*self._add_new_apn_btn_locator) Wait(self.marionette).until( expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until( expected.element_displayed(*self._apn_editor_page_locator))
def tap_caller_id_selection(self): menu_item = self.marionette.find_element(*self._caller_id_menu_item_locator) Wait(self.marionette).until(lambda m: not menu_item.get_attribute("aria-disabled")) element = self.marionette.find_element(*self._caller_id_selector_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() self.marionette.switch_to_frame()
def tap_network_operator(self): element = self.marionette.find_element(*self._network_op_locator) Wait(self.marionette).until( expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until( expected.element_displayed(*self._network_type_selector_locator))
def tap_forward_unanswered(self): element = self.marionette.find_element(*self._call_forwarding_unanswered_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until(expected.element_displayed(*self._call_forwarding_unanswered_page_locator)) self.marionette.switch_to_frame() Wait(self.marionette).until(lambda m: self.keyboard.is_keyboard_displayed) self.apps.switch_to_displayed_app()
def go_back_and_exit(self, app=None, add_statusbar_height=True): Wait(self.marionette).until( expected.element_enabled(self.root_element) and expected.element_displayed(self.root_element)) self.tap_element_from_system_app( self.root_element, add_statusbar_height=add_statusbar_height, x=20) app.wait_to_not_be_displayed() self.apps.switch_to_displayed_app()
def tap_voicemail(self): element = self.marionette.find_element(*self._voicemail_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until(expected.element_displayed(*self._voicemail_number_locator)) self.marionette.switch_to_frame() Wait(self.marionette).until(lambda m: self.keyboard.is_keyboard_displayed) self.apps.switch_to_displayed_app()
def tap_sim_1(self): element = self.marionette.find_element(*self._sim_1_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until(expected.element_displayed(*self._call_settings_page_locator)) menu_item = self.marionette.find_element(*self._caller_id_menu_item_locator) Wait(self.marionette, timeout=120).until(lambda m: not menu_item.get_attribute("aria-disabled"))
def tap_caller_id_selection(self): element = self.marionette.find_element( *self._caller_id_selector_locator) Wait(self.marionette).until( expected.element_displayed(element) and expected.element_enabled(element)) element.tap() self.marionette.switch_to_frame()
def tap_toggle_flash_button(self): initial_flash_mode = self.current_flash_mode toggle = self.marionette.find_element( *self._toggle_flash_button_locator) Wait(self.marionette).until(expected.element_enabled(toggle)) toggle.tap() Wait(self.marionette).until( lambda m: self.current_flash_mode != initial_flash_mode)
def tap_select_button(self): select = self.marionette.find_element(*self._select_button_locator) Wait(self.marionette).until(expected.element_enabled(select)) self.tap_element_from_system_app(select) # Fall back to app beneath the picker Wait(self.marionette).until(lambda m: self.apps.displayed_app.name != self.name) self.apps.switch_to_displayed_app()
def enable_bluetooth(self): self.marionette.find_element(*self._bluetooth_label_locator).tap() checkbox = self.marionette.find_element( *self._bluetooth_checkbox_locator) Wait(self.marionette).until(expected.element_selected(checkbox)) rename_device = self.marionette.find_element( *self._rename_my_device_button_locator) Wait(self.marionette).until(expected.element_enabled(rename_device))
def tap_call_forwarding(self): element = self.marionette.find_element(*self._call_forwarding_locator) Wait(self.marionette).until( expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until( expected.element_displayed(*self._call_forwarding_page_locator))
def tap_sim_1(self): element = self.marionette.find_element(*self._sim_1_locator) Wait(self.marionette).until( expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until( expected.element_displayed(*self._call_settings_page_locator))
def tap_auth_numbers(self): element = self.marionette.find_element(*self._auth_number_locator) Wait(self.marionette).until( expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until( expected.element_displayed(*self._auth_number_page_locator))
def tap_data_settings(self): element = self.marionette.find_element(*self._data_settings_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until(expected.element_displayed(*self._add_new_apn_btn_locator)) # also necessary to check for selections, since sometimes the button gets displayed first Wait(self.marionette).until(expected.element_displayed(*self._apn_item_locator))
def tap_next(self): next_button = Wait(self.marionette).until( expected.element_present(*self._next_button_locator)) Wait(self.marionette).until(expected.element_displayed(next_button)) Wait(self.marionette).until(expected.element_enabled(next_button)) # In b2g desktop builds, this sleep prevents intermittent failures time.sleep(0.2) next_button.tap()
def tap_grant_access(self): grant_access = self.marionette.find_element(*self._grant_access_button_locator) Wait(self.marionette).until(expected.element_enabled(grant_access)) grant_access.tap() # Go back to displayed Contacts app before waiting for the picker Wait(self.marionette).until(lambda m: self.apps.displayed_app.name == 'Contacts') self.apps.switch_to_displayed_app() from gaiatest.apps.contacts.regions.contact_import_picker import ContactImportPicker return ContactImportPicker(self.marionette)
def tap_cancel_reset(self): dialog_view = self.marionette.find_element(*self._reset_apn_page_locator) element = self.marionette.find_element(*self._cancel_btn_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until(lambda m: 'current' not in dialog_view.get_attribute('class')) Wait(self.marionette).until(expected.element_displayed(*self._reset_apn_btn_locator))
def tap_call_barring_all_cancel(self): element = self.marionette.find_element( *self._call_barring_all_cancel_button_locator) Wait(self.marionette).until( expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until( expected.element_displayed(*self._call_barring_page_locator))
def tap_fixed_dialing(self): element = self.marionette.find_element( *self._fixed_dialing_numbers_locator) Wait(self.marionette).until( expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until( expected.element_displayed(*self._fixed_dialing_page_locator))
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 go_back(self): back_button = self.root_element.find_element( *self._back_button_locator) Wait(self.marionette).until( expected.element_enabled(back_button) and expected.element_displayed(back_button)) back_button.tap() Wait(self.marionette).until( expected.element_not_displayed(back_button))
def tap_rename_my_device(self): _rename_my_device_button_locator = (By.CSS_SELECTOR, 'button.rename-device') _update_device_name_input_locator = (By.CSS_SELECTOR, 'input.settings-dialog-input') Wait(self.marionette, timeout=120).until( expected.element_displayed(*_rename_my_device_button_locator)) rename_my_device_button = self.marionette.find_element(*_rename_my_device_button_locator) Wait(self.marionette).until(expected.element_enabled(rename_my_device_button)) rename_my_device_button.tap() Wait(self.marionette, timeout=120).until( expected.element_displayed(*_update_device_name_input_locator))
def __init__(self, marionette): Base.__init__(self, marionette) Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._edit_preview_canvas_locator)))) # I have tried waiting for all the elements in the UI, but the crash # still occurs so the only solution I found was the hardcoded sleep - Bug 1111981 time.sleep(3) done = self.marionette.find_element(*self._crop_done_button_locator) Wait(self.marionette).until(expected.element_enabled(done))
def enable_fixed_dialing(self): element = self.marionette.find_element(*self._toggle_fixed_dialing_number_locator) Wait(self.marionette).until(expected.element_displayed(element) and expected.element_enabled(element)) element.tap() Wait(self.marionette).until(expected.element_displayed( *self._sim_pin_area_locator)) self.marionette.switch_to_frame() Wait(self.marionette).until(lambda m: self.keyboard.is_keyboard_displayed) self.apps.switch_to_displayed_app()
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) element = self.marionette.find_element(*self._back_button_locator) if element.is_displayed(): element.tap() self.marionette.switch_to_shadow_root() else: # This header has a close button instead of a back button self.marionette.switch_to_shadow_root() self.root_element.find_element(*self._close_button_locator).tap() Wait(self.marionette).until(expected.element_not_displayed(self.root_element))
def tap_select_button(self): select = self.marionette.find_element(*self._select_button_locator) Wait(self.marionette).until(expected.element_enabled(select)) try: select.tap() except (FrameSendFailureError, NoSuchWindowException): # The frame may close for Marionette but that's expected so we can continue - Bug 1065933 pass # Fall back to app beneath the picker Wait(self.marionette).until(lambda m: self.apps.displayed_app.name != self.name) self.apps.switch_to_displayed_app()
def tap_select_button(self): select = self.marionette.find_element(*self._select_button_locator) Wait(self.marionette).until(expected.element_enabled(select)) # Workaround for bug 1109213, where tapping on the button inside the app itself # makes Marionette spew out NoSuchWindowException errors x = select.rect['x'] + select.rect['width']//2 y = select.rect['y'] + select.rect['height']//2 self.marionette.switch_to_frame() self.marionette.find_element(*self._screen_locator).tap(x, y) # Fall back to app beneath the picker Wait(self.marionette).until(lambda m: self.apps.displayed_app.name != self.name) self.apps.switch_to_displayed_app()
def return_to_prev_menu(self, parent_view, exit_view, back_button = None): # TODO: remove tap with coordinates after Bug 1061698 is fixed if back_button is None: # because of th Bug 1061698, we need to locate the # right edge of the header and tap it # if we have the back_button, then tapping anywhere # within it should give the same result back_button = self.marionette.find_element(*self._header_locator) Wait(self.marionette).until(expected.element_enabled(back_button) and expected.element_displayed(back_button)) back_button.tap(25, 25) Wait(self.marionette).until(lambda m: 'current' not in exit_view.get_attribute('class')) Wait(self.marionette).until(lambda m: parent_view.rect['x'] == 0) Wait(self.marionette).until(lambda m: 'current' in parent_view.get_attribute('class'))