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


Python SelectionManager.first_caret_location方法代码示例

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


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

示例1: test_move_cursor_to_the_right_by_one_character

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import first_caret_location [as 别名]
    def test_move_cursor_to_the_right_by_one_character(self, el_id):
        self.open_test_html(self._cursor_html)
        el = self.marionette.find_element(By.ID, el_id)
        sel = SelectionManager(el)
        content_to_add = '!'
        target_content = sel.content
        target_content = target_content[:1] + content_to_add + target_content[1:]

        # Get first caret (x, y) at position 1 and 2.
        el.tap()
        sel.move_cursor_to_front()
        cursor0_x, cursor0_y = sel.cursor_location()
        first_caret0_x, first_caret0_y = sel.first_caret_location()
        sel.move_cursor_by_offset(1)
        first_caret1_x, first_caret1_y = sel.first_caret_location()

        # Tap the front of the input to make first caret appear.
        el.tap(cursor0_x, cursor0_y)

        # Move first caret.
        self.actions.flick(el, first_caret0_x, first_caret0_y,
                           first_caret1_x, first_caret1_y).perform()

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

示例2: test_move_cursor_to_front_by_dragging_caret_to_front

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import first_caret_location [as 别名]
    def test_move_cursor_to_front_by_dragging_caret_to_front(self, el_id):
        self.open_test_html(self._cursor_html)
        el = self.marionette.find_element(By.ID, el_id)
        sel = SelectionManager(el)
        content_to_add = '!'
        target_content = content_to_add + sel.content

        # Get first caret location at the front.
        el.tap()
        sel.move_cursor_to_front()
        dest_x, dest_y = sel.first_caret_location()

        # Tap to make first 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_cursor_to_end()
        sel.move_cursor_by_offset(1, backward=True)
        el.tap(*sel.cursor_location())
        src_x, src_y = sel.first_caret_location()

        # Move first 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()
        self.assertEqual(target_content, sel.content)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:28,代码来源:test_accessiblecaret_cursor_mode.py

示例3: test_move_cursor_to_front_by_dragging_caret_to_front_br_element

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import first_caret_location [as 别名]
    def test_move_cursor_to_front_by_dragging_caret_to_front_br_element(self):
        self.open_test_html(self._cursor_html)
        el = self.marionette.find_element(By.ID, self._contenteditable_id)
        sel = SelectionManager(el)
        content_to_add_1 = '!'
        content_to_add_2 = '\n\n'
        target_content = content_to_add_1 + content_to_add_2 + sel.content

        # Goal: the cursor position can be changed by dragging the caret from
        # the end of the content to the front br element. Because we cannot get
        # caret location if it's on a br element, we need to get the first caret
        # location then adding the new lines.

        # Get first caret location at the front.
        el.tap()
        sel.move_cursor_to_front()
        dest_x, dest_y = sel.first_caret_location()

        # Append new line to the front of the content.
        el.send_keys(content_to_add_2);

        # Tap to make first caret appear.
        el.tap()
        sel.move_cursor_to_end()
        sel.move_cursor_by_offset(1, backward=True)
        el.tap(*sel.cursor_location())
        src_x, src_y = sel.first_caret_location()

        # Move first 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_1).key_up(content_to_add_1).perform()
        self.assertEqual(target_content, sel.content)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:35,代码来源:test_accessiblecaret_cursor_mode.py

示例4: test_drag_swappable_carets

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import first_caret_location [as 别名]
    def test_drag_swappable_carets(self, el_id):
        self.open_test_html(self._selection_html)
        el = self.marionette.find_element(By.ID, el_id)
        sel = SelectionManager(el)
        original_content = sel.content
        words = original_content.split()
        self.assertTrue(len(words) >= 1, 'Expect at least one word in the content.')

        target_content1 = words[0]
        target_content2 = original_content[len(words[0]):]

        # Get the location of the carets at the end of the content for later
        # use.
        el.tap()
        sel.select_all()
        end_caret_x, end_caret_y = sel.second_caret_location()

        self.long_press_on_word(el, 0)

        # Drag the first caret to the end and back to where it was
        # immediately. The selection range should not be collapsed.
        caret1_x, caret1_y = sel.first_caret_location()
        self.actions.flick(el, caret1_x, caret1_y, end_caret_x, end_caret_y)\
                    .flick(el, end_caret_x, end_caret_y, caret1_x, caret1_y).perform()
        self.assertEqual(target_content1, sel.selected_content)

        # Drag the first caret to the end.
        caret1_x, caret1_y = sel.first_caret_location()
        self.actions.flick(el, caret1_x, caret1_y, end_caret_x, end_caret_y).perform()
        self.assertEqual(target_content2, sel.selected_content)
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:32,代码来源:test_accessiblecaret_selection_mode.py

示例5: test_drag_caret_from_front_to_end_across_columns

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import first_caret_location [as 别名]
    def test_drag_caret_from_front_to_end_across_columns(self):
        self.open_test_html('test_carets_columns.html')
        el = self.marionette.find_element(By.ID, 'columns-inner')
        sel = SelectionManager(el)
        content_to_add = '!'
        target_content = sel.content + content_to_add

        # Goal: the cursor position can be changed by dragging the caret from
        # the front to the end of the content.

        # Tap to make the cursor appear.
        before_image_1 = self.marionette.find_element(By.ID, 'before-image-1')
        before_image_1.tap()

        # Tap the front of the content to make first caret appear.
        sel.move_cursor_to_front()
        el.tap(*sel.cursor_location())
        src_x, src_y = sel.first_caret_location()
        dest_x, dest_y = el.size['width'], el.size['height']

        # Drag the first caret to the bottom-right corner of the element.
        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()
        self.assertEqual(target_content, sel.content)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:27,代码来源:test_accessiblecaret_cursor_mode.py

示例6: test_caret_not_appear_when_typing_in_scrollable_content

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import first_caret_location [as 别名]
    def test_caret_not_appear_when_typing_in_scrollable_content(self):
        self.open_test_html(self._cursor_html)
        el = self.marionette.find_element(By.ID, self._input_id)
        sel = SelectionManager(el)
        content_to_add = '!'
        target_content = sel.content + string.ascii_letters + content_to_add

        el.tap()
        sel.move_cursor_to_end()

        # Insert a long string to the end of the <input>, which triggers
        # ScrollPositionChanged event.
        el.send_keys(string.ascii_letters)

        # The caret should not be visible. If it does appear wrongly due to the
        # ScrollPositionChanged event, we can drag it to the front of the
        # <input> to change the cursor position.
        src_x, src_y = sel.first_caret_location()
        dest_x, dest_y = 0, 0
        self.actions.flick(el, src_x, src_y, dest_x, dest_y).perform()

        # The content should be inserted at the end of the <input>.
        el.send_keys(content_to_add)

        self.assertEqual(target_content, sel.content)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:27,代码来源:test_accessiblecaret_cursor_mode.py

示例7: test_dragging_caret_to_top_left_corner_after_timeout

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import first_caret_location [as 别名]
    def test_dragging_caret_to_top_left_corner_after_timeout(self, el_id):
        self.open_test_html(self._cursor_html)
        el = self.marionette.find_element(By.ID, el_id)
        sel = SelectionManager(el)
        content_to_add = '!'
        non_target_content = content_to_add + sel.content

        # Set caret timeout to be 1 second.
        timeout = 1
        self.marionette.set_pref(self.caret_timeout_ms_pref, timeout * 1000)

        # Set a 3x timeout margin to prevent intermittent test failures.
        timeout *= 3

        # Tap to make first 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_cursor_to_end()
        sel.move_cursor_by_offset(1, backward=True)
        el.tap(*sel.cursor_location())

        # Wait until first caret disappears, then pretend to move it to the
        # top-left corner of the input box.
        src_x, src_y = sel.first_caret_location()
        dest_x, dest_y = 0, 0
        self.actions.wait(timeout).flick(el, src_x, src_y, dest_x, dest_y).perform()

        self.actions.key_down(content_to_add).key_up(content_to_add).perform()
        self.assertNotEqual(non_target_content, sel.content)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:32,代码来源:test_accessiblecaret_cursor_mode.py

示例8: test_caret_not_jump_when_dragging_to_editable_content_boundary

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import first_caret_location [as 别名]
    def test_caret_not_jump_when_dragging_to_editable_content_boundary(self, el_id):
        self.open_test_html(self._cursor_html)
        el = self.marionette.find_element(By.ID, el_id)
        sel = SelectionManager(el)
        content_to_add = '!'
        non_target_content = sel.content + content_to_add

        # Goal: the cursor position is not changed after dragging the caret down
        # on the Y-axis.
        el.tap()
        sel.move_cursor_to_front()
        el.tap(*sel.cursor_location())
        x, y = sel.first_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:MichaelKohler,项目名称:gecko-dev,代码行数:20,代码来源:test_accessiblecaret_cursor_mode.py

示例9: test_move_cursor_to_end_by_dragging_caret_to_bottom_right_corner

# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import first_caret_location [as 别名]
    def test_move_cursor_to_end_by_dragging_caret_to_bottom_right_corner(self, el_id):
        self.open_test_html(self._cursor_html)
        el = self.marionette.find_element(By.ID, el_id)
        sel = SelectionManager(el)
        content_to_add = '!'
        target_content = sel.content + content_to_add

        # Tap the front of the input to make first caret appear.
        el.tap()
        sel.move_cursor_to_front()
        el.tap(*sel.cursor_location())

        # Move first caret to the bottom-right corner of the element.
        src_x, src_y = sel.first_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()

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


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