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 tap_order_by_last_name(self): last_name = Wait(self.marionette).until( expected.element_present(*self._order_by_last_name_switch_locator)) Wait(self.marionette).until(expected.element_displayed(last_name)) initial_state = self.is_custom_element_checked(last_name) last_name.tap() self.wait_for_custom_element_checked_state(last_name, checked=not(initial_state))
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 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 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 enable_passcode_lock(self): checkbox = Wait(self.marionette).until( expected.element_present(*self._passcode_checkbox_locator)) Wait(self.marionette).until(expected.element_displayed(checkbox)) checkbox.tap() section = self.marionette.find_element(*self._screen_lock_passcode_section_locator) Wait(self.marionette).until(lambda m: section.location['x'] == 0)
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 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 test_post_camera_preview(self): lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() # Turn off the geolocation prompt, and then launch the camera app self.apps.set_permission('Camera', 'geolocation', 'deny') self.camera = Camera(self.marionette) self.camera.launch() while (self.camera.current_flash_mode != 'off'): self.camera.tap_toggle_flash_button() time.sleep(2) self.marionette.switch_to_frame() camera_frame = Wait(self.marionette, timeout=120).until( expected.element_present(*self._camera_frame_locator)) camera_frame.tap() self.marionette.switch_to_frame(camera_frame) time.sleep(20) self.device.touch_home_button() time.sleep(10) self.device.turn_screen_off() print "" print "Running Post Camera Preview Test" self.runPowerTest("post_idle_camera_preview", "Camera", "camera")
def test_camera_picture(self): """https://moztrap.mozilla.org/manage/case/1296/""" lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() #self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name) # Turn off the geolocation prompt, and then launch the camera app self.apps.set_permission('Camera', 'geolocation', 'deny') self.camera = Camera(self.marionette) self.camera.launch() while (self.camera.current_flash_mode != 'off'): self.camera.tap_toggle_flash_button() time.sleep(2) self.marionette.switch_to_frame() camera_frame = Wait(self.marionette, timeout=120).until( expected.element_present(*self._camera_frame_locator)) camera_frame.tap() self.marionette.switch_to_frame(camera_frame) print "" print "Running Camera Picture Test" self.runPowerTest("camera_picture", "Camera", "camera", PICTURE_INTERVAL_TIME, self.take_picture)
def select_sim(self, sim): locators = [self._menuItem_carrier_sim1_locator, self._menuItem_carrier_sim2_locator] element = Wait(self.marionette).until( expected.element_present(*locators[sim])) Wait(self.marionette).until(expected.element_dispayed(element)) element.tap()
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_send_feedback(self): element = Wait(self.marionette).until( expected.element_present(*self._send_feedback_locator)) Wait(self.marionette).until(expected.element_displayed(element)) element.tap() Wait(self.marionette).until( expected.element_displayed(*self._feedback_choice_locator))
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_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_first_song(self): self.switch_to_active_view() song = Wait(self.marionette).until( expected.element_present(*self._first_song_locator)) song.tap() self.apps.switch_to_displayed_app() return PlayerView(self.marionette)
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() from gaiatest.apps.contacts.regions.contact_form import EditContact return EditContact(self.marionette)
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_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 confirm_suggestion_notice(self): confirm = Wait(self.marionette).until( expected.element_present( *self._search_suggestion_ok_button_locator)) Wait(self.marionette).until(expected.element_displayed(confirm)) confirm.tap() Wait(self.marionette).until(expected.element_not_displayed(confirm))
def open_change_home_screen(self): element = Wait(self.marionette).until( expected.element_present(*self._change_homescreen_locator)) Wait(self.marionette).until(expected.element_displayed(element)) element.tap() new_page = self.marionette.find_element(*self._change_homescreen_page_locator) Wait(self.marionette).until(lambda m: new_page.rect['x'] == 0 and new_page.is_displayed())
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 open_get_more_home_screen(self): element = Wait(self.marionette).until( expected.element_present(*self._get_more_homescreen_locator)) Wait(self.marionette).until(expected.element_displayed(element)) element.tap() self.marionette.switch_to_frame() Wait(self.marionette).until(expected.element_displayed(*self._pick_cancel_button_locator))
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 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 select_change_icon_layout(self): element = Wait(self.marionette).until( expected.element_present(*self._change_icon_layout_locator)) Wait(self.marionette).until(expected.element_displayed(element)) element.tap() self.marionette.switch_to_frame() Wait(self.marionette).until(expected.element_displayed(*self._confirm_layout_button_locator))
def test_post_camera_preview(self): lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() # Turn off the geolocation prompt, and then launch the camera app self.apps.set_permission('Camera', 'geolocation', 'deny') self.camera = Camera(self.marionette) self.camera.launch() while (self.camera.current_flash_mode != 'off'): self.camera.tap_toggle_flash_button(); time.sleep(2) self.marionette.switch_to_frame() camera_frame = Wait(self.marionette, timeout=120).until( expected.element_present(*self._camera_frame_locator)) camera_frame.tap() self.marionette.switch_to_frame(camera_frame) time.sleep(20) self.device.touch_home_button() time.sleep(10) self.device.turn_screen_off() print "" print "Running Post Camera Preview Test" self.runPowerTest("post_idle_camera_preview", "Camera", "camera")
def test_camera_video(self): """https://moztrap.mozilla.org/manage/case/1296/""" lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() #self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name) # Turn off the geolocation prompt, and then launch the camera app self.apps.set_permission('Camera', 'geolocation', 'deny') self.camera = Camera(self.marionette) self.camera.launch() while (self.camera.current_flash_mode != 'off'): self.camera.tap_toggle_flash_button(); time.sleep(2) time.sleep(5) self.camera.tap_switch_source() time.sleep(5) self.marionette.switch_to_frame() camera_frame = Wait(self.marionette, timeout=120).until( expected.element_present(*self._camera_frame_locator)) camera_frame.tap() self.marionette.switch_to_frame(camera_frame) self.camera.tap_capture() print "" print "Running Camera Video Test" self.runPowerTest("camera_video", "Camera", "camera") self.camera.tap_capture()
def tap_confirm(self): # TODO add a good wait here when Bug 1008961 is resolved time.sleep(1) self.marionette.switch_to_frame() confirm = Wait(self.marionette).until(expected.element_present(*self._confirm_install_button_locator)) Wait(self.marionette).until(expected.element_displayed(confirm)) confirm.tap()
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() from gaiatest.apps.contacts.regions.contact_form import EditContact return EditContact(self.marionette)
def tap_confirm_delay(self): element = Wait(self.marionette).until( expected.element_present(*self._confirm_delay_change_locator)) Wait(self.marionette).until(expected.element_displayed(element)) element.tap() self.apps.switch_to_displayed_app() Wait(self.marionette).until(expected.element_displayed(*self._delay_locator))
def connect_to_network(self, network_info): # Wait for the networks to be found this_network_locator = ('xpath', "//li/a/span[text()='%s']" % network_info['ssid']) this_network = Wait(self.marionette).until(expected.element_present(*this_network_locator)) this_network.tap() if network_info.get('keyManagement'): password = network_info.get('psk') or network_info.get('wep') if not password: raise Exception('No psk or wep key found in testvars for secured wifi network.') screen_width = int(self.marionette.execute_script('return window.innerWidth')) ok_button = self.marionette.find_element(*self._password_ok_button_locator) Wait(self.marionette).until(lambda m: (ok_button.location['x'] + ok_button.size['width']) == screen_width) password_input = self.marionette.find_element(*self._password_input_locator) Wait(self.marionette).until(expected.element_displayed(password_input)) password_input.send_keys(password) ok_button.tap() connected_message = self.marionette.find_element(*self._connected_message_locator) self.marionette.execute_script("arguments[0].scrollIntoView(false);", [connected_message]) timeout = max(self.marionette.timeout and self.marionette.timeout / 1000, 60) Wait(self.marionette, timeout, ignored_exceptions=StaleElementException).until( lambda m: m.find_element(*self._connected_message_locator).text == "Connected")
def go_back(self): element = Wait(self.marionette).until(expected.element_present(*self._header_locator)) Wait(self.marionette).until(expected.element_displayed(element)) # TODO: replace this hard coded value with tap on the back button, after Bug 1061698 is fixed element.tap(x=10) Wait(self.marionette).until(lambda m: m.execute_script( "return window.wrappedJSObject.Settings && window.wrappedJSObject.Settings._currentPanel === '#root'"))
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 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) # This sleep seems necessary, otherwise on device we get timeout failure on display search_box sometimes, see bug 1136791 import time time.sleep(10) search_toggle = Wait(self.marionette).until( expected.element_present(*self._search_toggle_locator)) Wait(self.marionette).until(expected.element_displayed(search_toggle)) search_toggle.tap() search_box = Wait(self.marionette).until( expected.element_present(*self._search_locator)) Wait(self.marionette).until(expected.element_displayed(search_box)) # This sleep is necessary, otherwise the search results are not shown on desktop b2g import time time.sleep(0.5) # search for the app search_box.send_keys(term) search_box.send_keys(Keys.RETURN) return SearchResults(self.marionette)
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 connect_to_network(self, network_info): # Wait for the networks to be found this_network_locator = ("xpath", "//li/a/span[text()='%s']" % network_info["ssid"]) this_network = Wait(self.marionette).until(expected.element_present(*this_network_locator)) this_network.tap() if network_info.get("keyManagement"): password = network_info.get("psk") or network_info.get("wep") if not password: raise Exception("No psk or wep key found in testvars for secured wifi network.") screen_width = int(self.marionette.execute_script("return window.innerWidth")) ok_button = self.marionette.find_element(*self._password_ok_button_locator) Wait(self.marionette).until(lambda m: (ok_button.location["x"] + ok_button.size["width"]) == screen_width) password_input = self.marionette.find_element(*self._password_input_locator) Wait(self.marionette).until(expected.element_displayed(password_input)) password_input.send_keys(password) ok_button.tap() connected_message = self.marionette.find_element(*self._connected_message_locator) self.marionette.execute_script("arguments[0].scrollIntoView(false);", [connected_message]) timeout = max(self.marionette.timeout and self.marionette.timeout / 1000, 60) Wait(self.marionette, timeout, ignored_exceptions=StaleElementException).until( lambda m: m.find_element(*self._connected_message_locator).text == "Connected" )
def tap_done(self): done = Wait(self.marionette).until(expected.element_present(*self._done_locator)) Wait(self.marionette).until(expected.element_displayed(done)) done.tap() view = self.marionette.find_element(*self._alarm_view_locator) Wait(self.marionette).until(lambda m: view.location['x'] == view.size['width']) return Clock(self.marionette)
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_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 enable_passcode_lock(self): # This wait would be in __init__ but lockscreen could be disabled meaning init would timeout element = Wait(self.marionette).until(expected.element_present(*self._passcode_enable_locator)) Wait(self.marionette).until(expected.element_displayed(element)) element.tap() section = self.marionette.find_element(*self._screen_lock_passcode_section_locator) Wait(self.marionette).until(lambda m: section.location['x'] == 0)