当前位置: 首页>>代码示例>>Python>>正文


Python SelectionManager.move_caret_to_front方法代码示例

本文整理汇总了Python中marionette_driver.selection.SelectionManager.move_caret_to_front方法的典型用法代码示例。如果您正苦于以下问题:Python SelectionManager.move_caret_to_front方法的具体用法?Python SelectionManager.move_caret_to_front怎么用?Python SelectionManager.move_caret_to_front使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marionette_driver.selection.SelectionManager的用法示例。


在下文中一共展示了SelectionManager.move_caret_to_front方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: word_location

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import move_caret_to_front [as 别名]
    def word_location(self, el, ordinal):
        '''Get the location (x, y) of the ordinal-th word in el.

        The ordinal starts from 0.

        Note: this function has a side effect which changes focus to the
        target element el.

        '''
        sel = SelectionManager(el)
        tokens = re.split(r'(\S+)', sel.content)  # both words and spaces
        words = tokens[0::2]                      # collect words at even indices
        spaces = tokens[1::2]                     # collect spaces at odd indices
        self.assertTrue(ordinal < len(words),
                        'Expect at least %d words in the content.' % ordinal)

        # Cursor position of the targeting word is behind the the first
        # character in the word. For example, offset to 'def' in 'abc def' is
        # between 'd' and 'e'.
        offset = sum(len(words[i]) + len(spaces[i]) for i in range(ordinal)) + 1

        # Move caret to the word.
        el.tap()
        sel.move_caret_to_front()
        sel.move_caret_by_offset(offset)
        x, y = sel.caret_location()

        return x, y
开发者ID:nikhilgupta23,项目名称:gecko-dev,代码行数:30,代码来源:test_selectioncarets.py

示例2: _first_word_location

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import move_caret_to_front [as 别名]
    def _first_word_location(self, el):
        '''Get the location (x, y) of the first word in el.

        Note: this function has a side effect which changes focus to the
        target element el.

        '''
        sel = SelectionManager(el)

        # Move caret behind the first character to get the location of the first
        # word.
        el.tap()
        sel.move_caret_to_front()
        sel.move_caret_by_offset(1)

        return sel.caret_location()
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:18,代码来源:test_selectioncarets.py

示例3: _test_move_caret_to_end_by_dragging_touch_caret_to_bottom_right_corner

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import move_caret_to_front [as 别名]
    def _test_move_caret_to_end_by_dragging_touch_caret_to_bottom_right_corner(self, el, assertFunc):
        sel = SelectionManager(el)
        content_to_add = '!'
        target_content = sel.content + content_to_add

        # Tap the front of the input to make touch caret appear.
        el.tap()
        sel.move_caret_to_front()
        el.tap(*sel.caret_location())

        # Move touch caret to the bottom-right corner of the element.
        src_x, src_y = sel.touch_caret_location()
        dest_x, dest_y = el.size['width'], el.size['height']
        self.actions.flick(el, src_x, src_y, dest_x, dest_y).perform()

        el.send_keys(content_to_add)
        assertFunc(target_content, sel.content)
开发者ID:LordJZ,项目名称:gecko-dev,代码行数:19,代码来源:test_touchcaret.py

示例4: test_caret_does_not_jump_when_dragging_to_editable_content_boundary

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import move_caret_to_front [as 别名]
    def test_caret_does_not_jump_when_dragging_to_editable_content_boundary(self):
        self.open_test_html()
        el = self._input
        sel = SelectionManager(el)
        content_to_add = '!'
        non_target_content = sel.content + content_to_add

        # Goal: the cursor position does not being changed after dragging the
        # caret down on the Y-axis.
        el.tap()
        sel.move_caret_to_front()
        el.tap(*sel.caret_location())
        x, y = sel.touch_caret_location()

        # Drag the caret down by 50px, and insert '!'.
        self.actions.flick(el, x, y, x, y + 50).perform()
        self.actions.key_down(content_to_add).key_up(content_to_add).perform()
        self.assertNotEqual(non_target_content, sel.content)
开发者ID:kleopatra999,项目名称:system-addons,代码行数:20,代码来源:test_touchcaret.py

示例5: word_location

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import move_caret_to_front [as 别名]
    def word_location(self, el, ordinal):
        '''Get the location (x, y) of the ordinal-th word in el.

        The ordinal starts from 0.

        Note: this function has a side effect which changes focus to the
        target element el.

        '''
        sel = SelectionManager(el)
        offset = self.word_offset(sel.content, ordinal)

        # Move caret to the word.
        el.tap()
        sel.move_caret_to_front()
        sel.move_caret_by_offset(offset)
        x, y = sel.caret_location()

        return x, y
开发者ID:kilikkuo,项目名称:gecko-dev,代码行数:21,代码来源:test_accessiblecaret_selection_mode.py

示例6: _test_move_caret_to_the_right_by_one_character

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import move_caret_to_front [as 别名]
    def _test_move_caret_to_the_right_by_one_character(self, el, assertFunc):
        sel = SelectionManager(el)
        content_to_add = "!"
        target_content = sel.content
        target_content = target_content[:1] + content_to_add + target_content[1:]

        # Get touch caret (x, y) at position 1 and 2.
        el.tap()
        sel.move_caret_to_front()
        caret0_x, caret0_y = sel.caret_location()
        touch_caret0_x, touch_caret0_y = sel.touch_caret_location()
        sel.move_caret_by_offset(1)
        touch_caret1_x, touch_caret1_y = sel.touch_caret_location()

        # Tap the front of the input to make touch caret appear.
        el.tap(caret0_x, caret0_y)

        # Move touch caret
        self.actions.flick(el, touch_caret0_x, touch_caret0_y, touch_caret1_x, touch_caret1_y).perform()

        self.actions.key_down(content_to_add).key_up(content_to_add).perform()
        assertFunc(target_content, sel.content)
开发者ID:kapeels,项目名称:gecko-dev,代码行数:24,代码来源:test_touchcaret.py

示例7: _long_press_to_select_word

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import move_caret_to_front [as 别名]
    def _long_press_to_select_word(self, el, wordOrdinal):
        sel = SelectionManager(el)
        original_content = sel.content
        words = original_content.split()
        self.assertTrue(wordOrdinal < len(words),
            'Expect at least %d words in the content.' % wordOrdinal)

        # Calc offset
        offset = 0
        for i in range(wordOrdinal):
            offset += (len(words[i]) + 1)

        # Move caret inside the word.
        el.tap()
        sel.move_caret_to_front()
        sel.move_caret_by_offset(offset)
        x, y = sel.caret_location()

        # Long press the caret position. Selection carets should appear, and the
        # word will be selected. On Windows, those spaces after the word
        # will also be selected.
        long_press_without_contextmenu(self.marionette, el, self._long_press_time, x, y)
开发者ID:LordJZ,项目名称:gecko-dev,代码行数:24,代码来源:test_selectioncarets_multiplerange.py

示例8: _test_move_caret_to_front_by_dragging_touch_caret_to_front_of_content

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import move_caret_to_front [as 别名]
    def _test_move_caret_to_front_by_dragging_touch_caret_to_front_of_content(self, el, assertFunc):
        sel = SelectionManager(el)
        content_to_add = "!"
        target_content = content_to_add + sel.content

        # Get touch caret location at the front.
        el.tap()
        sel.move_caret_to_front()
        dest_x, dest_y = sel.touch_caret_location()

        # Tap to make touch caret appear. Note: it's strange that when the caret
        # is at the end, the rect of the caret in <textarea> cannot be obtained.
        # A bug perhaps.
        el.tap()
        sel.move_caret_to_end()
        sel.move_caret_by_offset(1, backward=True)
        el.tap(*sel.caret_location())
        src_x, src_y = sel.touch_caret_location()

        # Move touch caret to the front of the input box.
        self.actions.flick(el, src_x, src_y, dest_x, dest_y).perform()

        self.actions.key_down(content_to_add).key_up(content_to_add).perform()
        assertFunc(target_content, sel.content)
开发者ID:kapeels,项目名称:gecko-dev,代码行数:26,代码来源:test_touchcaret.py


注:本文中的marionette_driver.selection.SelectionManager.move_caret_to_front方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。