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 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_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_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_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_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 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_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 _search_ad_duration(self): """ Try and determine ad duration. Refreshes state. :return: ad duration in seconds, if currently displayed in player """ self._refresh_state() if not (self._last_seen_player_state.player_ad_playing or self._player_measure_progress() == 0): return None if (self._last_seen_player_state.player_ad_playing and self._last_seen_video_state.duration): return self._last_seen_video_state.duration selector = '.html5-video-player .videoAdUiAttribution' wait = Wait(self.marionette, timeout=5) try: with self.marionette.using_context(Marionette.CONTEXT_CONTENT): wait.until(expected.element_present(By.CSS_SELECTOR, selector)) countdown = self.marionette.find_element(By.CSS_SELECTOR, selector) ad_time = self._time_pattern.search(countdown.text) if ad_time: ad_minutes = int(ad_time.group('minute')) ad_seconds = int(ad_time.group('second')) return 60 * ad_minutes + ad_seconds except (TimeoutException, NoSuchElementException): self.marionette.log('Could not obtain ' 'element: {}'.format(selector), level='WARNING') return None
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_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 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 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 search_ad_duration(self): """ :return: ad duration in seconds, if currently displayed in player """ if not (self.ad_playing or self.player_measure_progress() == 0): return None # If the ad is not Flash... if (self.ad_playing and self.video_src.startswith('mediasource') and self.duration): return self.duration selector = '#movie_player .videoAdUiAttribution' wait = Wait(self.marionette, timeout=5) try: with self.marionette.using_context('content'): wait.until(expected.element_present(By.CSS_SELECTOR, selector)) countdown = self.marionette.find_element(By.CSS_SELECTOR, selector) ad_time = self._time_pattern.search(countdown.text) if ad_time: ad_minutes = int(ad_time.group('minute')) ad_seconds = int(ad_time.group('second')) return 60 * ad_minutes + ad_seconds except (TimeoutException, NoSuchElementException): self.marionette.log('Could not obtain ' 'element: %s' % selector, level='WARNING') return None
def deactivate_autoplay(self): """ Attempt to turn off autoplay. Return True if successful. """ element_id = 'autoplay-checkbox' mn = self.marionette wait = Wait(mn, timeout=10) def get_status(el): script = 'return arguments[0].wrappedJSObject.checked' return mn.execute_script(script, script_args=[el]) try: with mn.using_context('content'): # the width, height of the element are 0, so it's not visible wait.until(expected.element_present(By.ID, element_id)) checkbox = mn.find_element(By.ID, element_id) # Note: in some videos, due to late-loading of sidebar ads, the # button is rerendered after sidebar ads appear & the autoplay # pref resets to "on". In other words, if you click too early, # the pref might get reset moments later. sleep(1) if get_status(checkbox): mn.execute_script('return arguments[0].' 'wrappedJSObject.click()', script_args=[checkbox]) self.marionette.log('Toggled autoplay.') autoplay = get_status(checkbox) self.marionette.log('Autoplay is %s' % autoplay) return (autoplay is not None) and (not autoplay) except (NoSuchElementException, TimeoutException): return False
def close(self, callback=None, force=False): """Closes the current chrome window. If this is the last remaining window, the Marionette session is ended. :param callback: Optional, function to trigger the window to open. It is triggered with the current :class:`BaseWindow` as parameter. Defaults to `window.open()`. :param force: Optional, forces the closing of the window by using the Gecko API. Defaults to `False`. """ self.switch_to() # Bug 1121698 # For more stable tests register an observer topic first prev_win_count = len(self.marionette.chrome_window_handles) if force or callback is None: self._windows.close(self.handle) else: callback(self) # Bug 1121698 # Observer code should let us ditch this wait code wait = Wait(self.marionette) wait.until(lambda m: len(m.chrome_window_handles) == prev_win_count - 1)
def attempt_ad_skip(self): """ Attempt to skip ad by clicking on skip-add button. Return True if clicking of ad-skip button occurred. """ # Wait for ad to load and become skippable if self.ad_playing: self.marionette.log('Waiting while ad plays') sleep(10) else: # no ad playing return False if self.ad_skippable: selector = '#movie_player .videoAdUiSkipContainer' wait = Wait(self.marionette, timeout=30) try: with self.marionette.using_context('content'): wait.until(expected.element_displayed(By.CSS_SELECTOR, selector)) ad_button = self.marionette.find_element(By.CSS_SELECTOR, selector) ad_button.click() self.marionette.log('Skipped ad.') return True except (TimeoutException, NoSuchElementException): self.marionette.log('Could not obtain ' 'element: %s' % selector, level='WARNING') return False
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 wait_for_notification(self, notification_class=BaseNotification, timeout=5): """Waits for the specified notification to be displayed. :param notification_class: Optional, the notification class to wait for. If `None` is specified it will wait for any notification to be closed. Defaults to `BaseNotification`. :param timeout: Optional, how long to wait for the expected notification. Defaults to 5 seconds. """ wait = Wait(self.marionette, timeout=timeout) if notification_class: if notification_class is BaseNotification: message = 'No notification was shown.' else: message = '{0} was not shown.'.format(notification_class.__name__) wait.until( lambda _: isinstance(self.notification, notification_class), message=message) else: message = 'Unexpected notification shown.' wait.until( lambda _: self.notification is None, message='Unexpected notification shown.')
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_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 __init__(self, marionette): Base.__init__(self, marionette) self.wait_to_be_displayed() self.apps.switch_to_displayed_app() element = Wait(self.marionette).until( expected.element_present(*self._panel_conversationview_locator)) Wait(self.marionette).until(lambda m: element.rect['x'] == 0 and element.is_displayed())
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 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 _switch_to_fxa_iframe(self): self.marionette.switch_to_frame() iframe = Wait(self.marionette, timeout=60).until( expected.element_present(*self._fxa_iframe_locator)) Wait(self.marionette).until(expected.element_displayed(iframe)) Wait(self.marionette, timeout=60).until(lambda m: iframe.get_attribute('data-url') != 'about:blank') self.marionette.switch_to_frame(iframe)
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 __init__(self, marionette): Base.__init__(self, marionette) self.switch_to_frame() # wait for the page to load email = Wait(self.marionette).until( expected.element_present(*self._email_locator)) Wait(self.marionette).until(lambda m: email.get_attribute('value') != '')
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_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 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 test_ev_certificate(self): with self.marionette.using_context('content'): self.marionette.navigate(self.url) # The lock icon should be shown self.assertIn( 'identity-secure', self.locationbar.connection_icon.value_of_css_property( 'list-style-image')) # Check the identity box self.assertEqual( self.locationbar.identity_box.get_attribute('className'), 'verifiedIdentity') # Get the information from the certificate cert = self.browser.tabbar.selected_tab.certificate address = self.security.get_address_from_certificate(cert) # Check the identity popup label displays self.assertEqual( self.locationbar.identity_organization_label.get_attribute( 'value'), cert['organization']) self.assertEqual( self.locationbar.identity_country_label.get_attribute('value'), '(' + address['country'] + ')') # Open the identity popup self.locationbar.open_identity_popup() # Check the idenity popup doorhanger self.assertEqual( self.identity_popup.element.get_attribute('connection'), 'secure-ev') # For EV certificates no hostname but the organization name is shown self.assertEqual(self.identity_popup.host.get_attribute('value'), cert['organization']) # Only the secure label is visible in the main view secure_label = self.identity_popup.view.main.secure_connection_label self.assertNotEqual(secure_label.value_of_css_property('display'), 'none') insecure_label = self.identity_popup.view.main.insecure_connection_label self.assertEqual(insecure_label.value_of_css_property('display'), 'none') self.identity_popup.view.main.expander.click() Wait(self.marionette).until( lambda _: self.identity_popup.view.security.selected) security_view = self.identity_popup.view.security # Only the secure label is visible in the security view secure_label = security_view.secure_connection_label self.assertNotEqual(secure_label.value_of_css_property('display'), 'none') insecure_label = security_view.insecure_connection_label self.assertEqual(insecure_label.value_of_css_property('display'), 'none') # Check the organization name self.assertEqual(security_view.owner.get_attribute('textContent'), cert['organization']) # Check the owner location string # More information: # hg.mozilla.org/mozilla-central/file/eab4a81e4457/browser/base/content/browser.js#l7012 location = self.browser.get_property( 'identity.identified.state_and_country') location = location.replace('%S', address['state'], 1).replace('%S', address['country']) location = address['city'] + '\n' + location self.assertEqual( security_view.owner_location.get_attribute('textContent'), location) # Check the verifier l10n_verifier = self.browser.get_property( 'identity.identified.verifier') l10n_verifier = l10n_verifier.replace('%S', cert['issuerOrganization']) self.assertEqual(security_view.verifier.get_attribute('textContent'), l10n_verifier) # Open the Page Info window by clicking the More Information button page_info = self.browser.open_page_info_window( lambda _: self.identity_popup.view.security.more_info_button.click( )) try: # Verify that the current panel is the security panel self.assertEqual(page_info.deck.selected_panel, page_info.deck.security) # Verify the domain listed on the security panel self.assertIn( cert['commonName'], page_info.deck.security.domain.get_attribute('value')) # Verify the owner listed on the security panel self.assertEqual( page_info.deck.security.owner.get_attribute('value'), cert['organization']) # Verify the verifier listed on the security panel self.assertEqual( page_info.deck.security.verifier.get_attribute('value'), cert['issuerOrganization']) finally: page_info.close() self.browser.focus()
def tap_first_app(self): self.marionette.find_element(*self._first_app_locator).tap() Wait(self.marionette).until( expected.element_displayed(*self._app_info_locator))
def tap_add_exception(self): self.marionette.find_element( *self._add_exceptions_menu_locator).tap() Wait(self.marionette).until( expected.element_displayed(*self._exception_app_list))
def tap_adjustment_ok(self): app = self.marionette.find_element(*self._app_locator) app.find_element(*self._ok_locator).tap() self.apps.switch_to_displayed_app() Wait(self.marionette).until( expected.element_displayed(*self._page_locator))
def switch_loc_adjustment(self): self.marionette.find_element( *self._loc_adjust_enable_locator).tap() Wait(self.marionette).until( expected.element_displayed(*self._add_exceptions_menu_locator))
def __init__(self, marionette): Base.__init__(self, marionette) page = self.marionette.find_element(*self._page_locator) Wait(self.marionette).until( lambda m: page.rect['x'] == 0 and page.is_displayed())
def wait_for_condition(self, method, timeout=None, message=None): Wait(self.marionette, timeout).until(method, message=message)
def verify_certificate_status(self, item): url, identity, cert_type = item['url'], item['identity'], item['type'] # Check the favicon # TODO: find a better way to check, e.g., mozmill's isDisplayed favicon_hidden = self.marionette.execute_script( """ return arguments[0].hasAttribute("hidden"); """, script_args=[self.browser.navbar.locationbar.identity_icon]) self.assertFalse(favicon_hidden) self.locationbar.open_identity_popup() # Check the type shown on the idenity popup doorhanger self.assertEqual( self.identity_popup.element.get_attribute('connection'), cert_type) self.identity_popup.view.main.expander.click() Wait(self.marionette).until( lambda _: self.identity_popup.view.security.selected) # Check the identity label self.assertEqual( self.locationbar.identity_organization_label.get_attribute( 'value'), identity) # Get the information from the certificate cert = self.browser.tabbar.selected_tab.certificate # Open the Page Info window by clicking the More Information button page_info = self.browser.open_page_info_window( lambda _: self.identity_popup.view.security.more_info_button.click( )) # Verify that the current panel is the security panel self.assertEqual(page_info.deck.selected_panel, page_info.deck.security) # Verify the domain listed on the security panel # If this is a wildcard cert, check only the domain if cert['commonName'].startswith('*'): self.assertIn( self.security.get_domain_from_common_name(cert['commonName']), page_info.deck.security.domain.get_attribute('value'), 'Expected domain found in certificate for ' + url) else: self.assertEqual( page_info.deck.security.domain.get_attribute('value'), cert['commonName'], 'Domain value matches certificate common name.') # Verify the owner listed on the security panel if identity != '': owner = cert['organization'] else: owner = page_info.get_property('securityNoOwner') self.assertEqual(page_info.deck.security.owner.get_attribute('value'), owner, 'Expected owner label found for ' + url) # Verify the verifier listed on the security panel self.assertEqual( page_info.deck.security.verifier.get_attribute('value'), cert['issuerOrganization'], 'Verifier matches issuer of certificate for ' + url) page_info.close()
def tap_save_image(self): Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present(*self._save_image_locator)))) self.marionette.find_element(*self._save_image_locator).tap()
def wait_for_senders_email_displayed(self): Wait(self.marionette).until( lambda m: m.find_element(*self._senders_email_locator).text != '')
def wait_for_panel_to_load(self): Wait(self.marionette).until(expected.element_displayed( Wait(self.marionette).until(expected.element_present( *self._event_title_input_locator))))
def current_ring_tone(self): element = self.marionette.find_element( *self._current_ring_tone_locator) Wait(self.marionette).until(lambda m: element.text != '') return element.text
def switch_to_frame(self): frame = Wait(self.marionette).until( expected.element_present(*self._frame_locator)) Wait(self.marionette).until(expected.element_displayed(frame)) self.marionette.switch_to_frame(frame)
def __init__(self, marionette): Base.__init__(self, marionette) self.marionette.switch_to_frame() view = self.marionette.find_element(*self._actions_menu_locator) Wait(self.marionette).until(lambda m: view.location['y'] == 0)
def wait_for_received_messages(self, interval=5, timeout=300): Wait(self.marionette, timeout).until( expected.element_displayed( Wait(self.marionette, timeout).until( expected.element_present( *self._received_message_content_locator))))
def _assert_n_errors(self, n): Wait(self.marionette).until(lambda _: (len( self._get_error_lines_including_ignored_errors()) == n)) self.assertEqual(0, len(self._get_error_lines()))
def wait_for_element_enabled(self, element, timeout=10): Wait(self.marionette, timeout) \ .until(lambda e: element.is_enabled(), message="Timed out waiting for element to be enabled")
def header_text(self): header = Wait(self.marionette).until( expected.element_present(*self._message_header_locator)) Wait(self.marionette).until(expected.element_displayed(header)) return header.text
def wait_for_subelement_displayed(self, parent, by, locator, timeout=None): Wait(self.marionette, timeout, ignored_exceptions=[NoSuchElementException, StaleElementException])\ .until(lambda m: parent.find_element(by, locator).is_displayed()) return parent.find_element(by, locator)
def wait_for_history_to_load(self, number_of_items=1): Wait(self.marionette).until(lambda m: len( m.find_elements(*self._history_item_locator)) == number_of_items)
def check_get_me_out_of_here_button(self, unsafe_page): button = self.marionette.find_element(By.ID, "getMeOutButton") button.click() Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( lambda mn: self.browser.default_homepage in mn.get_url())
def wait_for_element_exists(self, by, locator, timeout=None): Wait(self.marionette, timeout, ignored_exceptions=[NoSuchElementException, StaleElementException]) \ .until(lambda m: m.find_element(by, locator)) return self.marionette.find_element(by, locator)
def test_verify_phone_not_bricked(self): Wait(self.marionette).until( lambda m: self.apps.displayed_app.name == Homescreen.name)
def test_settings_app(self): settings = Settings(self.marionette) settings.launch() ################### Sound ###################### sound_page = settings.open_sound() self.take_screenshot('sound') GaiaImageCompareTestCase.scroll( self.marionette, 'down', sound_page.screen_element.size['height'], screen=sound_page.screen_element) self.take_screenshot('sound') ringtone_page = sound_page.tap_ring_tone_selector() self.take_screenshot('sound-ringtones') for i in range(0, 5): GaiaImageCompareTestCase.scroll( self.marionette, 'down', ringtone_page.screen_element.size['height'], screen=ringtone_page.screen_element) self.take_screenshot('sound-ringtones') ringtone_page.tap_exit() Wait(self.marionette).until( lambda m: sound_page.ring_tone_selector_visible) alerts_page = sound_page.tap_alerts_selector() self.take_screenshot('sound-alerts') for i in range(0, 5): GaiaImageCompareTestCase.scroll( self.marionette, 'down', alerts_page.screen_element.size['height'], screen=alerts_page.screen_element) self.take_screenshot('sound-alerts') alerts_page.tap_exit() Wait(self.marionette).until( lambda m: sound_page.ring_tone_selector_visible) manage_page = sound_page.tap_manage_tones_selector() self.take_screenshot('sound-manage_tones') for i in range(0, 5): GaiaImageCompareTestCase.scroll( self.marionette, 'down', manage_page.screen_element.size['height'], screen=manage_page.screen_element) self.take_screenshot('sound-manage_tones') manage_page.ring_tones[1].select_option() self.take_screenshot('sound-manage_tones-share') manage_page.cancel_share() manage_page.tap_exit() Wait(self.marionette).until( lambda m: sound_page.ring_tone_selector_visible) settings.return_to_prev_menu(settings.screen_element, sound_page.screen_element) #################### Display ###################### display_page = settings.open_display() self.take_screenshot('display') display_page.tap_timeout_selector() self.take_screenshot('display-timeout_values', top_frame=True) display_page.tap_timeout_confirmation() settings.return_to_prev_menu(settings.screen_element, display_page.screen_element) #################### Homescreen ###################### homescreen_page = settings.open_homescreen() self.take_screenshot('homescreen') homescreen_page.pick_wallpaper() self.take_screenshot('wallpaper') homescreen_page.cancel_pick_wallpaper() homescreen_page.select_change_icon_layout() self.take_screenshot('layout', top_frame=True) homescreen_page.confirm_icon_layout() homescreen_page.open_change_home_screen() self.take_screenshot('homescreen-change_homescreen') homescreen_page.open_get_more_home_screen() self.take_screenshot('homescreen-get_more_homescreen', top_frame=True) homescreen_page.cancel_get_more_home_screen() settings.return_to_prev_menu( homescreen_page.screen_element, homescreen_page.change_homescreen_screen_element) settings.return_to_prev_menu(settings.screen_element, homescreen_page.screen_element) ################### Search ###################### search_page = settings.open_search() self.take_screenshot('search') search_page.open_select_search_engine() self.take_screenshot('search-engine_list') search_page.close_select_search_engine() settings.return_to_prev_menu(settings.screen_element, search_page.screen_element) ################## Navigation ###################### nav_page = settings.open_navigation() self.take_screenshot('navigation') settings.return_to_prev_menu(settings.screen_element, nav_page.screen_element) ################# Notifications ###################### notif_page = settings.open_notification() self.take_screenshot('notification') settings.return_to_prev_menu(settings.screen_element, notif_page.screen_element) ################ Date and Time ###################### # Only the main page and Time Format selection is checked date_time_page = settings.open_date_and_time() self.take_screenshot('date_and_time') GaiaImageCompareTestCase.scroll( self.marionette, 'down', date_time_page.screen_element.size['height'], screen=date_time_page.screen_element) self.take_screenshot('date_and_time') date_time_page.disable_default_format() date_time_page.open_time_format() self.take_screenshot('date_and_time-time_format', top_frame=True) date_time_page.close_time_format() settings.return_to_prev_menu(settings.screen_element, date_time_page.screen_element) ############### Language ###################### # 'Get more languages' menu cannot be opened due to css bug language_page = settings.open_language() self.take_screenshot('language') language_page.open_select_language() self.take_screenshot('language-select', top_frame=True) language_page.close_select_language() settings.return_to_prev_menu(settings.screen_element, language_page.screen_element) # This involves app switching, and often would cause whitescreen issue under 319MB memory config # Please run in 512 or 1024 MB mode to avoid this issue ############### Keyboards ###################### keyboard_page = settings.open_keyboard() self.take_screenshot('keyboard') builtin_page = keyboard_page.tap_built_in_keyboards() self.take_screenshot('keyboard-built_in') builtin_page.tap_user_dictionary() self.take_screenshot('keyboard-user-dict') builtin_page.tap_user_dict_exit() builtin_page.tap_exit() keyboard_page.wait_until_page_ready() morekb_page = keyboard_page.tap_add_more_keyboards() self.take_screenshot('keyboard-more_kb') settings.return_to_prev_menu(keyboard_page.screen_element, morekb_page.screen_element) settings.return_to_prev_menu(settings.screen_element, keyboard_page.screen_element) ############## Themes ###################### themes_page = settings.open_themes() self.take_screenshot('themes') settings.return_to_prev_menu(settings.screen_element, themes_page.screen_element) ############# Addons ###################### addons_page = settings.open_addons() self.take_screenshot('addons') addons_page.tap_item(0) self.take_screenshot('addons-addon_enabled') addons_page.toggle_addon_status() # addons are enabled by default Wait(self.marionette).until(lambda m: not addons_page.is_addon_enabled) self.take_screenshot('addons-addon_disabled') addons_page.toggle_addon_status() # revert to original state settings.return_to_prev_menu(addons_page.screen_element, addons_page.details_screen_element) addons_page.tap_item(1) self.take_screenshot('addons-nouse_addon') settings.return_to_prev_menu(addons_page.screen_element, addons_page.details_screen_element) addons_page.tap_item(2) self.take_screenshot('addons-obsolete_addon') settings.return_to_prev_menu(addons_page.screen_element, addons_page.details_screen_element)
def wait_for_cards_view(self): Wait(self.marionette).until( lambda m: self.root_element.get_attribute('class') == 'active')
def test_dv_cert(self): with self.marionette.using_context('content'): self.marionette.navigate(self.url) # The lock icon should be shown self.assertIn( 'identity-secure', self.locationbar.connection_icon.value_of_css_property( 'list-style-image')) self.assertEqual( self.locationbar.identity_box.get_attribute('className'), 'verifiedDomain') # Open the identity popup self.locationbar.open_identity_popup() # Check the identity popup doorhanger self.assertEqual( self.identity_popup.element.get_attribute('connection'), 'secure') cert = self.browser.tabbar.selected_tab.certificate # The shown host equals to the certificate self.assertEqual( self.identity_popup.view.main.host.get_attribute('textContent'), cert['commonName']) # Only the secure label is visible in the main view secure_label = self.identity_popup.view.main.secure_connection_label self.assertNotEqual(secure_label.value_of_css_property('display'), 'none') insecure_label = self.identity_popup.view.main.insecure_connection_label self.assertEqual(insecure_label.value_of_css_property('display'), 'none') self.identity_popup.view.main.expander.click() Wait(self.marionette).until( lambda _: self.identity_popup.view.security.selected) # Only the secure label is visible in the security view secure_label = self.identity_popup.view.security.secure_connection_label self.assertNotEqual(secure_label.value_of_css_property('display'), 'none') insecure_label = self.identity_popup.view.security.insecure_connection_label self.assertEqual(insecure_label.value_of_css_property('display'), 'none') verifier_label = self.browser.get_property( 'identity.identified.verifier') self.assertEqual( self.identity_popup.view.security.verifier.get_attribute( 'textContent'), verifier_label.replace("%S", cert['issuerOrganization'])) def opener(mn): self.identity_popup.view.security.more_info_button.click() page_info_window = self.browser.open_page_info_window(opener) deck = page_info_window.deck self.assertEqual(deck.selected_panel, deck.security) self.assertEqual(deck.security.domain.get_attribute('value'), cert['commonName']) self.assertEqual(deck.security.owner.get_attribute('value'), page_info_window.get_property('securityNoOwner')) self.assertEqual(deck.security.verifier.get_attribute('value'), cert['issuerOrganization'])
def wait_for_centered(self): Wait(self.marionette).until(lambda m: self.is_centered)
def wait_for_cards_view_not_displayed(self): Wait(self.marionette).until( expected.element_not_displayed(self.root_element))
def test_launch_manifest(self): browser_manifest_url = 'app://search.gaiamobile.org/manifest.webapp' app = self.apps.launch('Browser', manifest_url=browser_manifest_url) self.assertTrue(app.frame) Wait(self.marionette).until(lambda m: 'search' in m.get_url())
def wait_for_no_card_displayed(self): Wait(self.marionette).until(lambda m: self.is_no_card_displayed)