示例#1
0
    def wait_for_content_ready(self):
        apps = GaiaApps(self.device.marionette)
        contacts = Contacts(self.device.marionette)

        Wait(self.device.marionette).until(
            lambda m: apps.displayed_app.name.lower() == 'contacts')
        apps.switch_to_displayed_app()

        Wait(self.device.marionette, 120, ignored_exceptions=(
            NoSuchElementException, ElementNotVisibleException)).until(
            lambda m: m.find_element(
                *contacts._contact_locator).is_displayed())
示例#2
0
    def wait_for_content_ready(self):
        apps = GaiaApps(self.device.marionette)
        contacts = Contacts(self.device.marionette)

        Wait(self.device.marionette).until(
            lambda m: apps.displayed_app.name.lower() == 'contacts')
        apps.switch_to_displayed_app()

        Wait(self.device.marionette,
             120,
             ignored_exceptions=(
                 NoSuchElementException,
                 ElementNotVisibleException)).until(lambda m: m.find_element(
                     *contacts._contact_locator).is_displayed())
示例#3
0
 def wait_for_content_ready(self):
     apps = GaiaApps(self.device.marionette)
     Wait(self.device.marionette).until(
         lambda m: apps.displayed_app.name.lower() == 'marketplace')
     apps.switch_to_displayed_app()
     if 'index.html' in self.device.marionette.get_url():
         # only switch to iframe if Marketplace is not packaged
         iframe = Wait(self.device.marionette).until(
             expected.element_present(
                 By.CSS_SELECTOR, 'iframe[src*="marketplace"]'))
         self.device.marionette.switch_to_frame(iframe)
     Wait(self.device.marionette, timeout=30).until(
         lambda m: 'loaded' in m.find_element(
             By.TAG_NAME, 'body').get_attribute('class').split())
示例#4
0
 def wait_for_content_ready(self):
     apps = GaiaApps(self.device.marionette)
     Wait(self.device.marionette).until(
         lambda m: apps.displayed_app.name.lower() == 'marketplace')
     apps.switch_to_displayed_app()
     iframe = Wait(self.device.marionette).until(
         expected.element_present(By.CSS_SELECTOR,
                                  'iframe[src*="marketplace"]'))
     self.device.marionette.switch_to_frame(iframe)
     # FIXME: The below *should* work, but doesn't... just doing an
     # arbitrary
     #Wait(self.device.marionette).until(
     #    lambda m: 'loaded' in m.find_element(
     #        By.TAG_NAME, 'body').get_attribute('class').split()
     time.sleep(30)
示例#5
0
    def run(self):
        self.device.gaiaApps.switch_to_displayed_app()  # switch to homescreen
        appicon = None

        # HACK: Bug 1026527 - perform a no-op swipe before running test to
        # workaround flame not processing input events properly
        self.device.executeCommands([['swipe_right']])

        icons = self.device.marionette.find_elements(
            By.CSS_SELECTOR, 'gaia-grid .icon:not(.placeholder)')
        for icon in icons:
            if icon.text == self.appname:
                self.device.marionette.execute_script(
                    'arguments[0].scrollIntoView(false);', [icon])
                appicon = icon
        if appicon is None:
            raise TestException("Cannot find icon for app with name "
                                "'%s'" % self.appname)

        tap_x = appicon.location['x'] + (appicon.size['width'] / 2)
        tap_y = appicon.location['y'] + (appicon.size['height'] / 2)

        self.start_capture()
        self.execute_actions([['tap', tap_x, tap_y]],
                             test_finished_after_actions=False)

        # wait for the app to be displayed
        apps = GaiaApps(self.device.marionette)
        Wait(self.device.marionette).until(
            lambda m: apps.displayed_app.name.lower() == self.appname.lower())
        apps.switch_to_displayed_app()

        self.wait_for_content_ready()

        self.logger.info("Content ready. Waiting an additional second to make "
                         "sure it has settled")
        time.sleep(1)

        self.test_finished()
        self.end_capture()
示例#6
0
    def run(self):
        self.device.gaiaApps.switch_to_displayed_app()  # switch to homescreen
        appicon = None

        # HACK: Bug 1026527 - perform a no-op swipe before running test to
        # workaround flame not processing input events properly
        self.device.executeCommands([['swipe_right']])

        icons = self.device.marionette.find_elements(
            By.CSS_SELECTOR, 'gaia-grid .icon:not(.placeholder)')
        for icon in icons:
            if icon.text == self.appname:
                self.device.marionette.execute_script(
                    'arguments[0].scrollIntoView(false);', [icon])
                appicon = icon
        if appicon is None:
            raise TestException("Cannot find icon for app with name "
                                "'%s'" % self.appname)

        tap_x = appicon.location['x'] + (appicon.size['width'] / 2)
        tap_y = appicon.location['y'] + (appicon.size['height'] / 2)

        self.start_capture()
        self.execute_actions([['tap', tap_x, tap_y]],
                             test_finished_after_actions=False)

        # wait for the app to be displayed
        apps = GaiaApps(self.device.marionette)
        Wait(self.device.marionette).until(
            lambda m: apps.displayed_app.name.lower() == self.appname.lower())
        apps.switch_to_displayed_app()

        self.wait_for_content_ready()

        self.logger.info("Content ready. Waiting an additional second to make "
                         "sure it has settled")
        time.sleep(1)

        self.test_finished()
        self.end_capture()
示例#7
0
 def touch_home_button(self):
     # ref: https://github.com/mozilla-b2g/gaia/blob/master/tests/python/gaia-ui-tests/gaiatest/gaia_test.py#L751
     apps = GaiaApps(self._marionette)
     if apps.displayed_app.name.lower() != 'homescreen':
         # touching home button will return to homescreen
         self._dispatch_home_button_event()
         Wait(self._marionette).until(
             lambda m: apps.displayed_app.name.lower() == 'homescreen')
         apps.switch_to_displayed_app()
     else:
         apps.switch_to_displayed_app()
         mode = self._marionette.find_element(By.TAG_NAME, 'body').get_attribute('class')
         self._dispatch_home_button_event()
         apps.switch_to_displayed_app()
         if 'edit-mode' in mode:
             # touching home button will exit edit mode
             Wait(self._marionette).until(lambda m: m.find_element(
                 By.TAG_NAME, 'body').get_attribute('class') != mode)
         else:
             # touching home button inside homescreen will scroll it to the top
             Wait(self._marionette).until(lambda m: m.execute_script(
                 "return window.wrappedJSObject.scrollY") == 0)
示例#8
0
文件: test.py 项目: wlach/eideticker
    def run(self):
        self.device.gaiaApps.switch_to_displayed_app()  # switch to homescreen
        appicon = None

        # HACK: Bug 1026527 - perform a no-op swipe before running test to
        # workaround flame not processing input events properly
        self.device.executeCommands([['swipe_right']])

        try:
            # look for the application icon in the dock first
            self.logger.info('Looking for app icon in dock')
            appicon = self.device.marionette.find_element(
                By.CSS_SELECTOR,
                '#footer .icon[aria-label="%s"]' % self.appname)
        except NoSuchElementException:
            # skip the everything.me page
            self.device.marionette.execute_async_script(
                'return window.wrappedJSObject.GridManager.goToPage(1, marionetteScriptFinished);')
            page_count = self.device.marionette.execute_script(
                'return window.wrappedJSObject.GridManager.pageHelper.getTotalPagesNumber();')
            for i in range(1, page_count):
                current_page = self.device.marionette.find_element(
                    By.CSS_SELECTOR, '#icongrid .page:not([aria-hidden=true])')
                try:
                    self.logger.info('Looking for app icon on page %s' % (i + 1))
                    appicon = current_page.find_element(
                        By.CSS_SELECTOR, '.icon[aria-label="%s"]' %
                        self.appname)
                    break
                except NoSuchElementException:
                    current_page_index = self.device.marionette.execute_script(
                        'return window.wrappedJSObject.GridManager.pageHelper.getCurrentPageNumber();')
                    if current_page_index < (page_count - 1):
                        self.device.marionette.execute_script(
                            'window.wrappedJSObject.GridManager.goToNextPage();')
                        Wait(self.device.marionette).until(
                            lambda m: m.find_element(By.TAG_NAME, 'body').get_attribute(
                                'data-transitioning') != 'true')
                    else:
                        raise TestException("Cannot find icon for app with name "
                                            "'%s'" % self.appname)

        tap_x = appicon.location['x'] + (appicon.size['width'] / 2)
        tap_y = appicon.location['y'] + (appicon.size['height'] / 2)

        self.start_capture()
        self.execute_actions([['tap', tap_x, tap_y]],
                             test_finished_after_actions=False)

        # wait for the app to be displayed
        apps = GaiaApps(self.device.marionette)
        Wait(self.device.marionette).until(
            lambda m: apps.displayed_app.name.lower() == self.appname.lower())
        apps.switch_to_displayed_app()

        self.wait_for_content_ready()

        self.logger.info("Content ready. Waiting an additional second to make "
                         "sure it has settled")
        time.sleep(1)

        self.test_finished()
        self.end_capture()