Пример #1
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()
Пример #2
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()
Пример #3
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
                key = Wait(self.marionette).until(
                    expected.element_present(*self._key_locator(val)))
                Wait(self.marionette).until(expected.element_displayed(key))
                action.move(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 == '@':
                    Wait(self.marionette).until(
                        lambda m: self._layout_page == 0)

        self.apps.switch_to_displayed_app()
Пример #4
0
Файл: app.py Проект: 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()
Пример #5
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()
Пример #6
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()
Пример #7
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()
Пример #8
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
                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)

        self.apps.switch_to_displayed_app()
Пример #9
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()
Пример #10
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)
Пример #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)
Пример #12
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()
Пример #13
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()
Пример #14
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()
Пример #15
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()
Пример #16
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()
Пример #17
0
Файл: app.py Проект: bjacob/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()
Пример #18
0
    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()
Пример #19
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()
Пример #20
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;"))
Пример #21
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)
        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()
Пример #22
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)
        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()
Пример #23
0
Файл: app.py Проект: 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()
Пример #24
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()
 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)
 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;"))
Пример #27
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()
Пример #28
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)