Example #1
0
 def long_press(self, key, timeout=2000):
     if len(key) == 1:
         self._switch_to_keyboard()
         key_obj = self.marionette.find_element(*self._key_locator(key))
         action = Actions(self.marionette)
         action.press(key_obj).wait(timeout / 1000).release().perform()
         self.marionette.switch_to_frame()
Example #2
0
    def send(self, string):
        self._switch_to_keyboard()
        for val in string:
            if ord(val) > 127:
                # this would get the right key to long press and switch to the right keyboard
                middle_key_val = self._find_key_for_longpress(val.encode('UTF-8'))
                self._switch_to_correct_layout(middle_key_val)

                # find the key to long press and press it to get the extended characters list
                middle_key = self.marionette.find_element(*self._key_locator(middle_key_val))
                action = Actions(self.marionette)
                action.press(middle_key).wait(2).perform()

                # find the targeted extended key to send
                target_key = self.marionette.find_element(*self._key_locator(val))
                action.move(target_key).release().perform()
            else:
                # after switching to correct keyboard, tap/click if the key is there
                self._switch_to_correct_layout(val)
                if self.is_element_present(*self._key_locator(val)):
                    self._tap(val)
                else:
                    assert False, 'Key %s not found on the keyboard' % val

            # after tap/click space key, it might get screwed up due to timing issue. adding 0.8sec for it.
            if ord(val) == int(self._space_key):
                time.sleep(0.8)
        self.marionette.switch_to_frame()
Example #3
0
 def long_press(self, key, timeout=2000):
     if len(key) == 1:
         self._switch_to_keyboard()
         key_obj = self.marionette.find_element(*self._key_locator(key))
         action = Actions(self.marionette)
         action.press(key_obj).wait(timeout / 1000).release().perform()
         self.marionette.switch_to_frame()
Example #4
0
File: app.py Project: 4gh/gaia
    def send(self, string):
        self.switch_to_keyboard()
        for val in string:
            if ord(val) > 127:
                # this would get the right key to long press and switch to the right keyboard
                middle_key_val = self._find_key_for_longpress(val.encode('UTF-8'))
                self._switch_to_correct_layout(middle_key_val)

                # find the key to long press and press it to get the extended characters list
                middle_key = self.marionette.find_element(*self._key_locator(middle_key_val))
                action = Actions(self.marionette)
                action.press(middle_key).wait(1).perform()

                # find the targeted extended key to send
                self.wait_for_element_displayed(*self._key_locator(val))
                target_key = self.marionette.find_element(*self._key_locator(val))
                action.move(target_key).release().perform()
            else:
                # after switching to correct keyboard, tap/click if the key is there
                self._switch_to_correct_layout(val)
                self._tap(val)

                # when we tap on '@' the layout switches to the default keyboard - Bug 996332
                if val == '@':
                    self.wait_for_condition(lambda m: self._layout_page == 0)

        self.apps.switch_to_displayed_app()
Example #5
0
 def move_slider(self, slider, dir_x):
     scale = self.marionette.find_element(*slider)
     finger = Actions(self.marionette)
     finger.press(scale)
     finger.move_by_offset(dir_x, 0)
     finger.release()
     finger.perform()
     time.sleep(2)
Example #6
0
 def _flick_to_image(self, direction):
     image = self.marionette.find_element(*self._current_image_locator)
     action = Actions(self.marionette)
     x_start = (image.size["width"] / 100) * (direction == "next" and 90 or 10)
     x_end = (image.size["width"] / 100) * (direction == "next" and 10 or 90)
     y_start = image.size["height"] / 4
     y_end = image.size["height"] / 4
     action.flick(image, x_start, y_start, x_end, y_end, 200).perform()
     Wait(self.marionette).until(lambda m: abs(image.location["x"]) >= image.size["width"])
Example #7
0
    def _flick_menu_down(self, locator):
        current_element = self.marionette.find_element(*self._current_element(*locator))
        next_element = self.marionette.find_element(*self._next_element(*locator))

        #TODO: update this with more accurate Actions
        action = Actions(self.marionette)
        action.press(current_element)
        action.move(next_element)
        action.release()
        action.perform()
Example #8
0
    def switch_keyboard_language(self, lang_code):
        keyboard_language_locator = (By.CSS_SELECTOR, ".keyboard-row button[data-keyboard='%s']" % lang_code)

        self.switch_to_keyboard()
        language_key = self.marionette.find_element(*self._language_key_locator)
        action = Actions(self.marionette)
        action.press(language_key).wait(1).perform()
        target_kb_layout = self.marionette.find_element(*keyboard_language_locator)
        action.move(target_kb_layout).release().perform()
        self.marionette.switch_to_frame()
Example #9
0
 def _flick_to_image(self, direction):
     image = self.marionette.find_element(*self._current_image_locator)
     action = Actions(self.marionette)
     x_start = (image.size['width'] / 100) * (direction == 'next' and 90 or 10)
     x_end = (image.size['width'] / 100) * (direction == 'next' and 10 or 90)
     y_start = image.size['height'] / 4
     y_end = image.size['height'] / 4
     action.flick(image, x_start, y_start, x_end, y_end, 200).perform()
     Wait(self.marionette).until(
         lambda m: abs(image.location['x']) >= image.size['width'])
Example #10
0
    def _flick_menu_up(self, locator):
        self.wait_for_element_displayed(*self._current_element(*locator))
        current_element = self.marionette.find_element(*self._current_element(*locator))
        next_element = self.marionette.find_element(*self._next_element(*locator))

        #TODO: update this with more accurate Actions
        action = Actions(self.marionette)
        action.press(next_element)
        action.move(current_element)
        action.release()
        action.perform()
Example #11
0
 def move_slider(self, slider, dir_x):
     scale = self.marionette.find_element(*slider)
     finger = Actions(self.marionette)
     finger.press(scale)
     finger.move_by_offset(dir_x, 0)
     finger.release()
     finger.perform()
     time.sleep(2)
Example #12
0
    def spin_hour24(self):
        hour24_picker = self.marionette.find_element(*self._current_element(*self._hour24_picker_locator))
        hour24_picker_move_y = hour24_picker.size['height'] * 2
        hour24_picker_mid_x = hour24_picker.size['width'] / 2
        hour24_picker_mid_y = hour24_picker.size['height'] / 2

        if self.hour24 == 'AM':
            Actions(self.marionette).flick(hour24_picker, hour24_picker_mid_x, hour24_picker_mid_y, hour24_picker_mid_x, hour24_picker_mid_y - hour24_picker_move_y)
        else:
            Actions(self.marionette).flick(hour24_picker, hour24_picker_mid_x, hour24_picker_mid_y, hour24_picker_mid_x, hour24_picker_mid_y + hour24_picker_move_y)

        time.sleep(1)
Example #13
0
File: app.py Project: MedMack/gaia
    def switch_keyboard_language(self, lang_code):
        # TODO At the moment this doesn't work because the UI has changed
        # An attempted repair ran into https://bugzilla.mozilla.org/show_bug.cgi?id=779284 (Modal dialog)

        keyboard_language_locator = (By.CSS_SELECTOR, ".keyboard-row button[data-keyboard='%s']" % lang_code)

        self.switch_to_keyboard()
        language_key = self.marionette.find_element(*self._language_key_locator)
        action = Actions(self.marionette)
        action.press(language_key).wait(1).perform()
        target_kb_layout = self.marionette.find_element(*keyboard_language_locator)
        action.move(target_kb_layout).release().perform()
        self.apps.switch_to_displayed_app()
Example #14
0
    def _flick_menu_down(self, locator):
        current_element = self.marionette.find_element(*self._current_element(*locator))
        next_element = self.marionette.find_element(*self._next_element(*locator))

        # TODO: update this with more accurate Actions
        action = Actions(self.marionette)
        action.press(current_element)
        action.move(next_element)
        action.release()
        action.perform()
Example #15
0
    def choose_extended_character(self,
                                  long_press_key,
                                  selection,
                                  movement=True):
        self.switch_to_keyboard()
        action = Actions(self.marionette)

        # after switching to correct keyboard, set long press if the key is there
        self._switch_to_correct_layout(long_press_key)
        try:
            key = self.marionette.find_element(
                *self._key_locator(long_press_key))
            self.wait_for_condition(lambda m: key.is_displayed)
        except:
            raise Exception('Key %s not found on the keyboard' %
                            long_press_key)
        action.press(key).wait(1).perform()

        # find the extended key and perform the action chain
        extend_keys = self.marionette.find_elements(
            *self._highlight_key_locator)
        if movement is True:
            action.move(extend_keys[selection - 1]).perform()
        action.release().perform()

        self.marionette.switch_to_frame()
Example #16
0
    def choose_extended_character(self,
                                  long_press_key,
                                  selection,
                                  movement=True):
        self._switch_to_keyboard()
        action = Actions(self.marionette)

        # after switching to correct keyboard, set long press if the key is there
        self._switch_to_correct_layout(long_press_key)
        key = self._key_locator(long_press_key)
        if self.is_element_present(*key):
            keyobj = self.marionette.find_element(*key)
            action.press(keyobj).wait(2).perform()
        else:
            assert False, 'Key %s not found on the keyboard' % long_press_key

        # find the extended key and perform the action chain
        extend_keys = self.marionette.find_elements(
            *self._highlight_key_locator)
        if movement == True:
            action.move(extend_keys[selection - 1]).perform()
        action.release().perform()
        time.sleep(1)

        self.marionette.switch_to_frame()
Example #17
0
    def _flick_menu_up(self, locator):
        self.wait_for_element_displayed(*self._current_element(*locator))
        current_element = self.marionette.find_element(*self._current_element(*locator))
        next_element = self.marionette.find_element(*self._next_element(*locator))

        #TODO: update this with more accurate Actions
        action = Actions(self.marionette)
        action.press(next_element)
        action.move(current_element)
        action.release()
        action.perform()
Example #18
0
File: app.py Project: Sob40/gaia
    def _flick_to_month(self, direction):
        """Flick current monthly calendar to next or previous month.

        @param direction: flick to next month if direction='next', else flick to previous month
        """
        action = Actions(self.marionette)

        current_monthly_calendar = self.marionette.find_element(*self._current_monthly_calendar_locator)
        flick_origin_x = current_monthly_calendar.size['width'] // 2
        flick_origin_y = current_monthly_calendar.size['height'] // 2
        flick_destination_x = 0 if direction == 'next' else 2 * flick_origin_x

        action.flick(current_monthly_calendar, flick_origin_x, flick_origin_y,
                     flick_destination_x, flick_origin_y)
        action.perform()
Example #19
0
    def test_browser_save_image(self):
        """
        https://moztrap.mozilla.org/manage/case/6889/
        """

        # Check that there are no images on sdcard before saving
        self.assertEqual(0, len(self.data_layer.sdcard_files('.jpeg')))

        search = Search(self.marionette)
        search.launch()

        browser = search.go_to_url(self.test_url)
        browser.switch_to_content()

        # Long tap on the image inside the browser content
        image = self.marionette.find_element('css selector', 'img')
        Actions(self.marionette).\
            press(image).\
            wait(3).\
            release().\
            wait(1).\
            perform()

        activities = Activities(self.marionette)
        activities.tap_save_image()

        system = System(self.marionette)
        system.wait_for_notification_toaster_displayed()
        system.wait_for_notification_toaster_not_displayed()

        self.assertEqual(1, len(self.data_layer.sdcard_files('.jpeg')))
Example #20
0
 def _activate_edit_mode(self):
     app = self.marionette.find_element(*self._visible_apps_locator)
     Actions(self.marionette). \
         press(app).\
         wait(3).\
         release(). \
         perform()
    def test_music_album_mp3(self):
        """
        https://moztrap.mozilla.org/manage/case/4031/
        """

        music_app = Music(self.marionette)
        music_app.launch()
        music_app.wait_for_music_tiles_displayed()
        self.take_screenshot()

        # switch to albums view
        list_view = music_app.tap_albums_tab()
        self.take_screenshot()

        # check that albums (at least one) are available
        albums = list_view.media
        self.assertGreater(len(albums), 0, 'The mp3 file could not be found')

        # select an album
        sublist_view = albums[0].tap_first_album()
        self.take_screenshot()
        # select play
        # This wait is timing out because of bug 862156
        player_view = sublist_view.tap_play()
        # play for a short duration
        play_time = time.strptime('00:03', '%M:%S')
        Wait(self.marionette).until(
            lambda m: player_view.player_elapsed_time >= play_time,
            message='Mp3 sample did not start playing')

        ff_button = self.marionette.find_element(
            *self._player_controls_next_locator)
        Actions(self.marionette).tap(ff_button).perform()
        self.take_screenshot()
Example #22
0
    def flick_frequency_dialer_up(self):
        dialer = self.marionette.find_element(*self._frequency_dialer_locator)

        dialer_x_center = int(dialer.size['width'] / 2)
        dialer_y_center = int(dialer.size['height'] / 2)
        Actions(self.marionette).flick(dialer, dialer_x_center,
                                       dialer_y_center, 0, 800, 800).perform()
    def test_music_songs_3gp(self):
        """https://moztrap.mozilla.org/manage/case/4031/"""

        music_app = Music(self.marionette)
        music_app.launch()
        music_app.wait_for_music_tiles_displayed()
        self.take_screenshot()

        # switch to songs view
        list_view = music_app.tap_songs_tab()

        # check that songs (at least one) are available
        songs = list_view.media
        self.assertGreater(len(songs), 0, 'The 3gp file could not be found')
        self.take_screenshot()

        player_view = songs[0].tap_first_song()

        play_time = time.strptime('00:03', '%M:%S')
        Wait(self.marionette).until(
            lambda m: player_view.player_elapsed_time >= play_time,
            message='3gp sample did not start playing')

        # validate playback
        self.assertTrue(player_view.is_player_playing(),
                        'The player is not playing')

        # select stop, then FF to the end of the song
        player_view.tap_play()
        ff_button = self.marionette.find_element(
            *self._player_controls_next_locator)
        Actions(self.marionette).tap(ff_button).perform()
        self.take_screenshot()
Example #24
0
    def _tap_page_switching_key(self, val):
        locator = (self._page_switching_key_locator[0],
                   self._page_switching_key_locator[1] % val)

        self.wait_for_element_displayed(*locator)
        key = self.marionette.find_element(*locator)
        Actions(self.marionette).press(key).wait(0.1).release().perform()
Example #25
0
File: app.py Project: bjacob/gaia
 def _tap(self, val):
     try:
         self.wait_for_condition(lambda m: m.find_element(*self._key_locator(val)).is_displayed())
         key = self.marionette.find_element(*self._key_locator(val))
         Actions(self.marionette).press(key).wait(0.1).release().perform()
     except (NoSuchElementException, ElementNotVisibleException):
         self.marionette.log('Key %s not found on the keyboard' % val)
         raise
Example #26
0
 def add_minute(self):
     current = self._current(self._minutes_picker_locator)
     minute = current.text
     next = current.find_element(By.XPATH, 'following-sibling::*')
     # TODO: Bug 1129907 - Unable to use precise actions to select timepicker values in Gaia
     # TODO: Bug 1031456 - invoking js event without release() loses context
     Actions(self.marionette).press(next).move(current).perform()
     Wait(self.marionette).until(lambda m: self.minute != minute)
Example #27
0
 def dial_phone_number(self, value):
     for i in value:
         if i == "+":
             zero_button = self.marionette.find_element(By.CSS_SELECTOR, 'div.keypad-key[data-value="0"]')
             Actions(self.marionette).long_press(zero_button, 1.2).perform()
         else:
             self.marionette.find_element(By.CSS_SELECTOR, 'div.keypad-key[data-value="%s"]' % i).tap()
             time.sleep(0.25)
Example #28
0
 def activate_edit_mode(self):
     app = self.marionette.find_element(*self._visible_icons_locator)
     Actions(self.marionette).\
         press(app).\
         wait(3).\
         release().\
         perform()
     self.wait_for_element_displayed(By.CSS_SELECTOR, 'div.dockWrapper ol[style*="transition: -moz-transform 0.5ms ease 0s;"]')
Example #29
0
 def long_press(self, key, timeout=2000):
     if len(key) == 1:
         self._switch_to_keyboard()
         key_obj = self.marionette.find_element(*self._key_locator(key))
         from marionette.marionette import Actions
         Actions(self.marionette).long_press(key_obj, timeout).perform()
         time.sleep(timeout / 1000 + 1)
         self.marionette.switch_to_frame()
Example #30
0
    def test_delete_app(self):

        # install app
        self.marionette.switch_to_frame()
        self.marionette.execute_script('navigator.mozApps.install("%s")' %
                                       self.MANIFEST)

        # click YES on the installation dialog and wait for icon displayed
        self.wait_for_element_displayed(*self._yes_button_locator)
        yes = self.marionette.find_element(*self._yes_button_locator)
        self.marionette.tap(yes)
        self.APP_INSTALLED = True

        # wait for the app to be installed and the notification banner to be available
        self.wait_for_element_displayed(*self._notification_banner_locator)
        notification = self.marionette.find_element(
            *self._notification_banner_locator).text
        self.assertEqual('%s installed' % self.APP_NAME, notification)
        self.wait_for_element_not_displayed(*self._notification_banner_locator)

        self.marionette.switch_to_frame(self.homescreen.frame)
        self.assertTrue(self.is_element_present(*self._icon_locator),
                        "The installed app can't be found")

        # switch pages until the app is found
        while not self.marionette.find_element(
                *self._icon_locator).is_displayed():
            self._go_to_next_page()

        # check that the app is available
        app_icon = self.marionette.find_element(*self._icon_locator)
        self.assertTrue(app_icon.is_displayed())

        # go to edit mode
        Actions(self.marionette). \
            press(app_icon). \
            wait(3). \
            release(). \
            perform()

        # delete the app
        delete_button = app_icon.find_element(*self._delete_app_locator)
        self.marionette.tap(delete_button)

        self.wait_for_element_displayed(*self._confirm_delete_locator)
        delete = self.marionette.find_element(*self._confirm_delete_locator)
        self.marionette.tap(delete)
        self.APP_INSTALLED = False

        self.wait_for_element_not_present(*self._icon_locator)

        # return to normal mode
        self.marionette.switch_to_frame()
        self._touch_home_button()

        # check that the app is no longer available
        with self.assertRaises(AssertionError):
            self.apps.launch(self.APP_NAME)
    def test_that_app_can_be_launched_from_cards_view(self):
        """https://moztrap.mozilla.org/manage/case/2462/"""

        cards_view = CardsView(self.marionette)
        self.assertFalse(cards_view.is_cards_view_displayed,
                         'Cards view not expected to be visible')

        # Pull up the cards view
        self.device.hold_home_button()
        cards_view.wait_for_cards_view()

        # Wait till it really displayed
        _cards_view_locator = ('id', 'cards-view')
        self.wait_for_condition(
            lambda m: m.find_element(*_cards_view_locator).is_displayed())

        time.sleep(5)
        cards = self.marionette.find_elements('css selector',
                                              'ul#cards-list li.card')
        cards_num = len(cards)

        current = -1
        for i in range(cards_num):
            # parse the cards for the displayed card
            for attr in cards[i].get_attribute('style').split(';'):
                if 'opacity: 1' in attr:
                    current = i

        # if there is cards, don't run
        if current != -1:
            choose = random.randint(0, cards_num - 1)
            card_name = self.marionette.find_elements(
                'css selector', 'ul#cards-list li.card')[choose].text

            current_frame = self.apps.displayed_app.frame
            final_x_position = current_frame.size['width']
            # start swipe from center of window
            start_x_position = final_x_position // 2
            start_y_position = current_frame.size['height'] // 2

            # swipe forward to get another app card
            move = choose - current
            if move > 0:
                final_x_position = final_x_position * (-1)
            if move != 0:
                for i in range(abs(move)):
                    Actions(self.marionette).flick(current_frame,
                                                   start_x_position,
                                                   start_y_position,
                                                   final_x_position,
                                                   start_y_position).perform()

            self.wait_for_condition(lambda m: 'opacity: 1;' in m.find_elements(
                'css selector', 'ul#cards-list li.card')[choose].get_attribute(
                    'style'))
            self.marionette.find_elements(
                'css selector', 'ul#cards-list li.card')[choose].tap()
            self.assertEqual(self.apps.displayed_app.name, card_name)
Example #32
0
    def _flick_to_image(self, direction):
        action = Actions(self.marionette)

        current_image = self.marionette.find_element(*self._current_image_locator)
        current_image_move_x = current_image.size["width"] / 2
        current_image_mid_x = current_image.size["width"] / 2
        current_image_mid_y = current_image.size["height"] / 2

        if direction == "next":
            action.flick(
                current_image,
                current_image_mid_x,
                current_image_mid_y,
                current_image_mid_x - current_image_move_x,
                current_image_mid_y,
            )
        else:
            action.flick(
                current_image,
                current_image_mid_x,
                current_image_mid_y,
                current_image_mid_x + current_image_move_x,
                current_image_mid_y,
            )

        action.perform()
        self.wait_for_element_displayed(*self._current_image_locator)
Example #33
0
    def open_utility_tray(self):
        statusbar = self.marionette.find_element(*self._status_bar_locator)
        statusbar_x = int(statusbar.size['width'])
        statusbar_y_start = int(statusbar.size['height'] / 2)
        statusbar_y_end = int(statusbar.size['height'] * 160)
        Actions(self.marionette).flick(statusbar, statusbar_x, statusbar_y_start, statusbar_x, statusbar_y_end, 100).perform()

        from gaiatest.apps.system.regions.utility_tray import UtilityTray
        return UtilityTray(self.marionette)
Example #34
0
File: app.py Project: orivier/gaia
    def open_utility_tray(self):
        body = self.marionette.find_element(By.TAG_NAME, 'body')
        statusbar = self.marionette.find_element(*self._status_bar_locator)
        statusbar_x = int(statusbar.size['width']/2)
        statusbar_y_end = int(body.size['height'])
        Actions(self.marionette).press(statusbar).move_by_offset(statusbar_x, statusbar_y_end).release().perform()

        from gaiatest.apps.system.regions.utility_tray import UtilityTray
        return UtilityTray(self.marionette)
Example #35
0
File: app.py Project: mmalecki/gaia
 def activate_edit_mode(self):
     app = self.marionette.find_element(*self._visible_icons_locator)
     Actions(self.marionette).\
         press(app).\
         wait(3).\
         release().\
         perform()
     self.wait_for_condition(lambda m: self.marionette.execute_script(
         "return window.wrappedJSObject.Homescreen.isInEditMode()"))
Example #36
0
 def open_context_menu(self):
     test = self.marionette.find_element(*self._landing_page_locator)
     Actions(self.marionette).\
         press(test, 0, 0).\
         wait(3).\
         release().\
         perform()
     from gaiatest.apps.homescreen.regions.context_menu import ContextMenu
     return ContextMenu(self.marionette)
Example #37
0
    def swipe_to_next_app(self):
        current_frame = self.apps.displayed_app.frame

        start_x_position = current_frame.size['width']
        start_y_position = current_frame.size['height'] // 2

        # swipe backward to get next app card
        Actions(self.marionette).flick(current_frame, start_x_position,
                                       start_y_position, 0,
                                       start_y_position).perform()
Example #38
0
File: app.py Project: 6a68/gaia
    def _flick_to_month(self, direction):
        """Flick current monthly calendar to next or previous month.

        @param direction: flick to next month if direction='next', else flick to previous month
        """
        action = Actions(self.marionette)

        month = self.marionette.find_element(
            *self._current_monthly_calendar_locator)
        month_year = self.current_month_year

        x_start = (month.size['width'] / 100) * (direction == 'next' and 90 or 10)
        x_end = (month.size['width'] / 100) * (direction == 'next' and 10 or 90)
        y_start = month.size['height'] / 4
        y_end = month.size['height'] / 4

        action.flick(month, x_start, y_start, x_end, y_end, 200).perform()

        Wait(self.marionette).until(lambda m: self.current_month_year != month_year)
Example #39
0
    def tap_switch_source(self):
        self.wait_for_element_displayed(*self._switch_button_locator)
        switch = self.marionette.find_element(*self._switch_button_locator)
        # TODO: Use marionette.tap(_switch_button_locator) to switch camera mode
        Actions(self.marionette).press(switch).move_by_offset(
            0, 0).release().perform()

        self.wait_for_condition(lambda m: m.find_element(
            *self._controls_locator).get_attribute('data-enabled') == 'true')
        self.wait_for_capture_ready()
Example #40
0
File: app.py Project: philsmd/gaia
    def _flick_to_month(self, direction):
        """Flick current monthly calendar to next or previous month.

        @param direction: flick to next month if direction='next', else flick to previous month
        """
        action = Actions(self.marionette)

        month = self.marionette.find_element(
            *self._current_monthly_calendar_locator)
        month_year = self.current_month_year

        x_start = (month.size['width'] / 100) * (direction == 'next' and 90 or 10)
        x_end = (month.size['width'] / 100) * (direction == 'next' and 10 or 90)
        y_start = month.size['height'] / 4
        y_end = month.size['height'] / 4

        action.flick(month, x_start, y_start, x_end, y_end, 200).perform()

        Wait(self.marionette).until(lambda m: self.current_month_year != month_year)
Example #41
0
 def activate_edit_mode(self):
     app = self.marionette.find_element(*self._homescreen_all_icons_locator)
     Actions(self.marionette).\
         press(app).\
         wait(3).\
         release().\
         perform()
     self.wait_for_condition(lambda m: app.is_displayed())
     # Ensure that edit mode is active
     self.wait_for_condition(lambda m: self.is_edit_mode_active)
Example #42
0
 def move_app_to_position(self, app_position, to_position):
     app_elements = self.app_elements
     Actions(self.marionette).\
         press(app_elements[app_position]).\
         wait(3).\
         move(app_elements[to_position]).\
         wait(1).\
         release().\
         wait(1).\
         perform()
Example #43
0
    def send(self, string):
        self.switch_to_keyboard()
        for val in string:
            if ord(val) > 127:
                # this would get the right key to long press and switch to the right keyboard
                middle_key_val = self._find_key_for_longpress(val.encode('UTF-8'))
                self._switch_to_correct_layout(middle_key_val)

                # find the key to long press and press it to get the extended characters list
                middle_key = self.marionette.find_element(*self._key_locator(middle_key_val))
                action = Actions(self.marionette)
                action.press(middle_key).wait(1).perform()

                # find the targeted extended key to send
                target_key = self.marionette.find_element(*self._key_locator(val))
                action.move(target_key).release().perform()
            else:
                # after switching to correct keyboard, tap/click if the key is there
                self._switch_to_correct_layout(val)
                self._tap(val)

        self.marionette.switch_to_frame()
Example #44
0
 def test_three_fingers(self):
   testAction = self.marionette.absolute_url("testAction.html")
   self.marionette.navigate(testAction)
   start_one = self.marionette.find_element("id", "button1")
   start_two = self.marionette.find_element("id", "button2")
   element1 = self.marionette.find_element("id", "button3")
   element2 = self.marionette.find_element("id", "button4")
   multi_action = MultiActions(self.marionette)
   action1 = Actions(self.marionette)
   action2 = Actions(self.marionette)
   action3 = Actions(self.marionette)
   action1.press(start_one).move_by_offset(0,300).release()
   action2.press(element1).wait().wait(5).release()
   action3.press(element2).wait().wait().release()
   multi_action.add(action1).add(action2).add(action3).perform()
   expected = "button1-touchstart"
   self.wait_for_condition(lambda m: m.execute_script("return document.getElementById('button1').innerHTML;") == expected)
   self.assertEqual("button2-touchmove-touchend", self.marionette.execute_script("return document.getElementById('button2').innerHTML;"))
   button3_text = self.marionette.execute_script("return document.getElementById('button3').innerHTML;")
   button4_text = self.marionette.execute_script("return document.getElementById('button4').innerHTML;")
   self.assertTrue("button3-touchstart-touchend" in button3_text)
   self.assertTrue("button4-touchstart-touchend" in button4_text)
   self.assertTrue(int(button3_text.rsplit("-")[-1]) >= 5000)
   self.assertTrue(int(button4_text.rsplit("-")[-1]) >= 5000)
Example #45
0
File: app.py Project: MedMack/gaia
    def choose_extended_character(self, long_press_key, selection, movement=True):
        self.switch_to_keyboard()
        action = Actions(self.marionette)

        # after switching to correct keyboard, set long press if the key is there
        self._switch_to_correct_layout(long_press_key)
        self.wait_for_element_displayed(*self._key_locator(long_press_key))
        key = self.marionette.find_element(*self._key_locator(long_press_key))
        action.press(key).wait(1).perform()

        # find the extended key and perform the action chain
        extend_keys = self.marionette.find_elements(*self._highlight_key_locator)
        if movement is True:
            action.move(extend_keys[selection - 1]).perform()
        action.release().perform()

        self.apps.switch_to_displayed_app()
Example #46
0
 def test_move_offset_element(self):
   testAction = self.marionette.absolute_url("testAction.html")
   self.marionette.navigate(testAction)
   start = self.marionette.find_element("id", "button1")
   ele = self.marionette.find_element("id", "button3")
   multi_action = MultiActions(self.marionette)
   action1 = Actions(self.marionette)
   action2 = Actions(self.marionette)
   action1.press(start).move_by_offset(0,300).wait().release()
   action2.press(ele).wait(5).release()
   multi_action.add(action1).add(action2).perform()
   expected = "button1-touchstart"
   self.wait_for_condition(lambda m: m.execute_script("return document.getElementById('button1').innerHTML;") == expected)
   self.assertEqual("button2-touchmove-touchend", self.marionette.execute_script("return document.getElementById('button2').innerHTML;"))
   self.assertTrue("button3-touchstart-touchend" in self.marionette.execute_script("return document.getElementById('button3').innerHTML;"))
Example #47
0
File: app.py Project: houqp/gaia
    def choose_extended_character(self, long_press_key, selection, movement=True):
        self.switch_to_keyboard()
        action = Actions(self.marionette)

        # after switching to correct keyboard, set long press if the key is there
        self._switch_to_correct_layout(long_press_key)
        try:
            key = self.marionette.find_element(*self._key_locator(long_press_key))
            self.wait_for_condition(lambda m: key.is_displayed)
        except:
            raise Exception("Key %s not found on the keyboard" % long_press_key)
        action.press(key).wait(1).perform()

        # find the extended key and perform the action chain
        extend_keys = self.marionette.find_elements(*self._highlight_key_locator)
        if movement is True:
            action.move(extend_keys[selection - 1]).perform()
        action.release().perform()

        self.marionette.switch_to_frame()
Example #48
0
    def choose_extended_character(self, long_press_key, selection, movement=True):
        self._switch_to_keyboard()
        action = Actions(self.marionette)

        # after switching to correct keyboard, set long press if the key is there
        self._switch_to_correct_layout(long_press_key)
        key = self._key_locator(long_press_key)
        if self.is_element_present(*key):
            keyobj = self.marionette.find_element(*key)
            action.press(keyobj).wait(2).perform()
        else:
            assert False, 'Key %s not found on the keyboard' % long_press_key

        # find the extended key and perform the action chain
        extend_keys = self.marionette.find_elements(*self._highlight_key_locator)
        if movement is True:
            action.move(extend_keys[selection - 1]).perform()
        action.release().perform()
        time.sleep(1)

        self.marionette.switch_to_frame()
Example #49
0
    def test_edge_gestures(self):
        '''
        Test swiping between apps with edge gestures
        As this is non-default (ie pref set) Gaia behaviour I have eschewed app objects
        '''

        # Swipe to the left on the displayed frame
        displayed_frame = self.apps.displayed_app.frame
        action = Actions(self.marionette)
        action.flick(displayed_frame, 0, 100, -200, 0, 50).perform()

        self.wait_for_condition(lambda m: self.apps.displayed_app.name == self._apps_under_test[0])

        # Swipe to the right
        displayed_frame = self.apps.displayed_app.frame
        action = Actions(self.marionette)
        action.flick(displayed_frame, displayed_frame.size['width'], 100, 200, 0, 50).perform()

        self.wait_for_condition(lambda m: self.apps.displayed_app.name == self._apps_under_test[1])
Example #50
0
 def double_tap_image(self):
     image = self.marionette.find_element(*self._current_image_locator)
     action = Actions(self.marionette)
     action.double_tap(image)
     action.perform()