Ejemplo n.º 1
0
 def scroll(self):
     start = self.marionette.find_element(By.CSS_SELECTOR, "#views-tiles .tile")
     distance = self.marionette.execute_script(
         "return arguments[0].scrollHeight", script_args=[self.marionette.find_element(By.ID, "views-tiles")]
     )
     self.logger.debug("Scrolling through music albums")
     smooth_scroll(self.marionette, start, "y", -1, distance, increments=20, scroll_back=True)
Ejemplo n.º 2
0
 def scroll(self):
     start = self.marionette.find_element(*self.gallery._gallery_items_locator)
     distance = self.marionette.execute_script(
         "return arguments[0].scrollHeight", script_args=[self.marionette.find_element(By.ID, "thumbnails")]
     )
     self.logger.debug("Scrolling through gallery thumbnails")
     smooth_scroll(self.marionette, start, "y", -1, distance, increments=20, scroll_back=True)
Ejemplo n.º 3
0
 def scroll(self):
     start = self.marionette.execute_script(
         'return window.wrappedJSObject.Browser.currentTab.dom;',
         new_sandbox=False)
     self.logger.debug('Scrolling through browser content')
     smooth_scroll(self.marionette, start, 'y', -1, 2000,
                   increments=20, scroll_back=True)
Ejemplo n.º 4
0
 def scroll(self):
     start = self.marionette.find_element(*self.contacts._contact_locator)
     distance = self.marionette.execute_script(
         "return arguments[0].scrollHeight", script_args=[self.marionette.find_element(By.ID, "groups-container")]
     )
     self.logger.debug("Scrolling through contacts")
     smooth_scroll(self.marionette, start, "y", -1, distance, increments=20, scroll_back=True)
Ejemplo n.º 5
0
 def scroll(self):
     start = self.marionette.find_element(By.CSS_SELECTOR, "#thumbnails .thumbnail")
     distance = self.marionette.execute_script(
         "return arguments[0].scrollHeight", script_args=[self.marionette.find_element(By.ID, "thumbnails")]
     )
     self.logger.debug("Scrolling through video thumbnails")
     smooth_scroll(self.marionette, start, "y", -1, distance, increments=20, scroll_back=True)
Ejemplo n.º 6
0
 def scroll(self):
     start = self.marionette.find_element(By.CSS_SELECTOR, "#root .menu-item")
     distance = self.marionette.execute_script(
         "return arguments[0].scrollHeight",
         script_args=[self.marionette.find_element(By.CSS_SELECTOR, "#root > div")],
     )
     self.logger.debug("Scrolling through settings")
     smooth_scroll(self.marionette, start, "y", -1, distance, increments=20, scroll_back=True)
Ejemplo n.º 7
0
 def test_smooth_scroll(self):
     testAction = self.marionette.absolute_url("testAction.html")
     self.marionette.navigate(testAction)
     button = self.marionette.find_element(By.ID, "button2")
     self.assertFalse(self.marionette.execute_script("{}; return elementInViewport(document.getElementById('buttonScroll'));" .format(elf.check_in_viewport)))
     smooth_scroll(self.marionette, button, "y",  -1, 800)
     buttonScroll = self.marionette.find_element(By.ID, "buttonScroll")
     self.wait_for_condition(lambda m: m.execute_script("{}; return elementInViewport(arguments[0]);".format(self.check_in_viewport, [buttonScroll]) == True))
     self.assertEqual("button2-touchstart", self.marionette.execute_script("return document.getElementById('button2').innerHTML;"))
Ejemplo n.º 8
0
 def scroll(self):
     start = self.marionette.find_element(
         By.CSS_SELECTOR, '#thumbnails .thumbnail')
     distance = self.marionette.execute_script(
         'return arguments[0].scrollHeight',
         script_args=[self.marionette.find_element(By.ID, 'thumbnails')])
     self.logger.debug('Scrolling through video thumbnails')
     smooth_scroll(self.marionette, start, 'y', -1, distance,
                   increments=20, scroll_back=True)
Ejemplo n.º 9
0
 def scroll(self):
     start = self.marionette.find_element(
         By.CSS_SELECTOR, '#views-tiles .tile')
     distance = self.marionette.execute_script(
         'return arguments[0].scrollHeight',
         script_args=[self.marionette.find_element(By.ID, 'views-tiles')])
     self.logger.debug('Scrolling through music albums')
     smooth_scroll(self.marionette, start, 'y', -1, distance,
                   increments=20, scroll_back=True)
Ejemplo n.º 10
0
 def scroll(self):
     # TODO Needs updating/fixing once we can pre-populate emails
     emails = self.marionette.find_elements(By.CLASS_NAME, "msg-header-author")
     # We're dynamically adding these elements from a template, and the
     # first one found is blank.
     Wait(self.marionette, timeout=30).until(lambda m: emails[0].get_attribute("innerHTML"))
     emails = self.marionette.find_elements(By.CLASS_NAME, "msg-header-author")
     self.logger.debug("Scrolling through emails")
     smooth_scroll(self.marionette, emails[0], "y", -1, 2000, increments=20, scroll_back=True)
Ejemplo n.º 11
0
 def test_smooth_scroll(self):
     testAction = self.marionette.absolute_url("testAction.html")
     self.marionette.navigate(testAction)
     button = self.marionette.find_element("id", "button2")
     self.assertFalse(self.marionette.execute_script("%s; return elementInViewport(document.getElementById('buttonScroll'));" % self.check_in_viewport))
     smooth_scroll(self.marionette, button, "y",  -1, 800)
     buttonScroll = self.marionette.find_element("id", "buttonScroll")
     self.wait_for_condition(lambda m: m.execute_script("%s; return elementInViewport(arguments[0]);" % self.check_in_viewport, [buttonScroll]) == True)
     self.assertEqual("button2-touchstart", self.marionette.execute_script("return document.getElementById('button2').innerHTML;"))
Ejemplo n.º 12
0
 def scroll(self):
     start = self.marionette.find_element(
         By.CSS_SELECTOR, '#root .menu-item')
     distance = self.marionette.execute_script(
         'return arguments[0].scrollHeight',
         script_args=[self.marionette.find_element(
             By.CSS_SELECTOR, '#root > div')])
     self.logger.debug('Scrolling through settings')
     smooth_scroll(self.marionette, start, 'y', -1, distance,
                   increments=20, scroll_back=True)
Ejemplo n.º 13
0
    def scroll(self, locator, direction, distance, increments=None):
        """scroll - uses smooth_scroll method in gestures.py.

        direction = 'up' or 'down' (page location)
        distance = total distance to travel
        increments = rate of scroll
        perform release afterwards """

        screen = self.marionette.find_element(*locator)
        vector = 0
        axis = "x"
        if direction == "up" or direction == "down":
            axis = "y"
        #
        # define direction.
        if direction == "up" or direction == "left":
            vector = -1

        smooth_scroll(self.marionette, screen, axis, vector, distance, increments)
Ejemplo n.º 14
0
    def scroll(self, locator, direction, distance, increments=None):
        """scroll - uses smooth_scroll method in gestures.py.

        direction = 'up' or 'down' (page location)
        distance = total distance to travel
        increments = rate of scroll
        perform release afterwards """

        screen = self.marionette.find_element(*locator)
        vector = 0
        axis = 'x'
        if direction == 'up' or direction == 'down':
            axis = 'y'
        #
        # define direction.
        if direction == 'up' or direction == 'left':
            vector = -1

        smooth_scroll(self.marionette, screen, axis, vector, distance,
                      increments)
Ejemplo n.º 15
0
    def scroll_app(self, app_name):
        touch_duration = float(200)

        apps = gaiatest.GaiaApps(self.marionette)
        #wait up to 30secs for the elements we want to show up
        self.marionette.set_search_timeout(30000)

        if app_name == 'Homescreen':
            action = Actions(self.marionette)
            landing_page = self.marionette.find_element('id', 'landing-page')
            action.flick(
                landing_page,
                landing_page.size['width'] / 100 * 90,
                landing_page.size['width'] / 2,
                landing_page.size['width'] / 100 * 10,
                landing_page.size['width'] / 2, touch_duration).perform()
            first_page = self.marionette.find_elements('css selector', '.page')[0]
            action.flick(
                first_page,
                first_page.size['width'] / 100 * 10,
                first_page.size['width'] / 2,
                first_page.size['width'] / 100 * 90,
                first_page.size['width'] / 2, touch_duration).perform()
        elif app_name == 'Contacts':
            name = self.marionette.find_element("css selector", ".contact-item p > strong")
            MarionetteWait(self.marionette, 30).until(lambda m: name.is_displayed())
            smooth_scroll(self.marionette, name, "y", -1, 5000, scroll_back=False)
        elif app_name == 'Browser':
            self.marionette.execute_script("return window.wrappedJSObject.Browser.navigate('http://taskjs.org/');", new_sandbox=False)
            MarionetteWait(self.marionette, 30).until(lambda m: 'http://taskjs.org/' == m.execute_script('return window.wrappedJSObject.Browser.currentTab.url;', new_sandbox=False))
            MarionetteWait(self.marionette, 30).until(lambda m: not m.execute_script('return window.wrappedJSObject.Browser.currentTab.loading;', new_sandbox=False))
            # check when the tab's document is ready
            tab_frame = self.marionette.execute_script("return window.wrappedJSObject.Browser.currentTab.dom;")
            self.marionette.switch_to_frame(tab_frame)
            MarionetteWait(self.marionette, 30).until(lambda m: m.execute_script('return window.document.readyState;', new_sandbox=False) == 'complete')
            # we have to fire smooth_scroll from the browser app, so let's go back
            self.marionette.switch_to_frame()
            apps.launch(app_name)  # since the app is launched, launch will switch us back to the app frame without relaunching
            tab_dom = self.marionette.execute_script("return window.wrappedJSObject.Browser.currentTab.dom;", new_sandbox=False)
            smooth_scroll(self.marionette, tab_dom, "y", -1, 5000, scroll_back=True)
        elif app_name == 'Email':
            email = self.marionette.find_element("class name", "msg-header-author")
            MarionetteWait(self.marionette, 30).until(lambda m: email.is_displayed() or not email.get_attribute('hidden'))
            emails = self.marionette.find_elements("class name", "msg-header-author")
            #we're dynamically adding these elements from a template, and the first one found is blank.
            MarionetteWait(self.marionette, 30).until(lambda m: emails[0].get_attribute('innerHTML'))
            emails = self.marionette.find_elements("class name", "msg-header-author")
            smooth_scroll(self.marionette, emails[0], "y", -1, 2000, scroll_back=True)
Ejemplo n.º 16
0
    def scroll_app(self, app_name):
        touch_duration = float(200)

        #wait up to 30secs for the elements we want to show up
        self.marionette.set_search_timeout(30000)

        if app_name.lower() == 'homescreen':
            action = Actions(self.marionette)
            landing_page = self.marionette.find_element('id', 'landing-page')
            self.logger.debug('Swiping to first page of apps')
            action.flick(
                landing_page,
                landing_page.size['width'] / 100 * 90,
                landing_page.size['width'] / 2,
                landing_page.size['width'] / 100 * 10,
                landing_page.size['width'] / 2, touch_duration).perform()
            first_page = self.marionette.find_elements('css selector', '.page')[0]
            self.logger.debug('Swiping back to home screen')
            action.flick(
                first_page,
                first_page.size['width'] / 100 * 10,
                first_page.size['width'] / 2,
                first_page.size['width'] / 100 * 90,
                first_page.size['width'] / 2, touch_duration).perform()
        elif app_name.lower() == 'contacts':
            name = self.marionette.find_element("css selector", ".contact-item p > strong")
            MarionetteWait(self.marionette, 30).until(lambda m: name.is_displayed())
            self.logger.debug('Scrolling through contacts')
            smooth_scroll(self.marionette, name, "y", -1, 5000, scroll_back=False)
        elif app_name.lower() == 'browser':
            tab_dom = self.marionette.execute_script("return window.wrappedJSObject.Browser.currentTab.dom;", new_sandbox=False)
            self.logger.debug('Scrolling through browser content')
            smooth_scroll(self.marionette, tab_dom, "y", -1, 5000, scroll_back=True)
        elif app_name.lower() == 'email':
            email = self.marionette.find_element("class name", "msg-header-author")
            MarionetteWait(self.marionette, 30).until(lambda m: email.is_displayed() or not email.get_attribute('hidden'))
            emails = self.marionette.find_elements("class name", "msg-header-author")
            #we're dynamically adding these elements from a template, and the first one found is blank.
            MarionetteWait(self.marionette, 30).until(lambda m: emails[0].get_attribute('innerHTML'))
            emails = self.marionette.find_elements("class name", "msg-header-author")
            self.logger.debug('Scrolling through emails')
            smooth_scroll(self.marionette, emails[0], "y", -1, 2000, scroll_back=True)
Ejemplo n.º 17
0
    def scroll_app(self, app_name):
        touch_duration = float(200)

        apps = gaiatest.GaiaApps(self.marionette)
        #wait up to 30secs for the elements we want to show up
        self.marionette.set_search_timeout(30000)

        if app_name == 'Homescreen':
            action = Actions(self.marionette)
            landing_page = self.marionette.find_element('id', 'landing-page')
            action.flick(landing_page, landing_page.size['width'] / 100 * 90,
                         landing_page.size['width'] / 2,
                         landing_page.size['width'] / 100 * 10,
                         landing_page.size['width'] / 2,
                         touch_duration).perform()
            first_page = self.marionette.find_elements('css selector',
                                                       '.page')[0]
            action.flick(first_page, first_page.size['width'] / 100 * 10,
                         first_page.size['width'] / 2,
                         first_page.size['width'] / 100 * 90,
                         first_page.size['width'] / 2,
                         touch_duration).perform()
        elif app_name == 'Contacts':
            name = self.marionette.find_element("css selector",
                                                ".contact-item p > strong")
            MarionetteWait(self.marionette,
                           30).until(lambda m: name.is_displayed())
            smooth_scroll(self.marionette,
                          name,
                          "y",
                          -1,
                          5000,
                          scroll_back=False)
        elif app_name == 'Browser':
            self.marionette.execute_script(
                "return window.wrappedJSObject.Browser.navigate('http://taskjs.org/');",
                new_sandbox=False)
            MarionetteWait(
                self.marionette,
                30).until(lambda m: 'http://taskjs.org/' == m.execute_script(
                    'return window.wrappedJSObject.Browser.currentTab.url;',
                    new_sandbox=False))
            MarionetteWait(
                self.marionette, 30
            ).until(lambda m: not m.execute_script(
                'return window.wrappedJSObject.Browser.currentTab.loading;',
                new_sandbox=False))
            # check when the tab's document is ready
            tab_frame = self.marionette.execute_script(
                "return window.wrappedJSObject.Browser.currentTab.dom;")
            self.marionette.switch_to_frame(tab_frame)
            MarionetteWait(self.marionette,
                           30).until(lambda m: m.execute_script(
                               'return window.document.readyState;',
                               new_sandbox=False) == 'complete')
            # we have to fire smooth_scroll from the browser app, so let's go back
            self.marionette.switch_to_frame()
            apps.launch(
                app_name
            )  # since the app is launched, launch will switch us back to the app frame without relaunching
            tab_dom = self.marionette.execute_script(
                "return window.wrappedJSObject.Browser.currentTab.dom;",
                new_sandbox=False)
            smooth_scroll(self.marionette,
                          tab_dom,
                          "y",
                          -1,
                          5000,
                          scroll_back=True)
        elif app_name == 'Email':
            email = self.marionette.find_element("class name",
                                                 "msg-header-author")
            MarionetteWait(self.marionette,
                           30).until(lambda m: email.is_displayed() or
                                     not email.get_attribute('hidden'))
            emails = self.marionette.find_elements("class name",
                                                   "msg-header-author")
            #we're dynamically adding these elements from a template, and the first one found is blank.
            MarionetteWait(
                self.marionette,
                30).until(lambda m: emails[0].get_attribute('innerHTML'))
            emails = self.marionette.find_elements("class name",
                                                   "msg-header-author")
            smooth_scroll(self.marionette,
                          emails[0],
                          "y",
                          -1,
                          2000,
                          scroll_back=True)