本文整理汇总了Python中marionette_driver.marionette.Actions.flick方法的典型用法代码示例。如果您正苦于以下问题:Python Actions.flick方法的具体用法?Python Actions.flick怎么用?Python Actions.flick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marionette_driver.marionette.Actions
的用法示例。
在下文中一共展示了Actions.flick方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: chain_flick
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
def chain_flick(marionette, wait_for_condition, expected1, expected2):
testAction = marionette.absolute_url("testAction.html")
marionette.navigate(testAction)
button = marionette.find_element(By.ID, "button1")
action = Actions(marionette)
action.flick(button, 0, 0, 0, 200).perform()
wait_for_condition_else_raise(marionette, wait_for_condition, expected1,"return document.getElementById('button1').innerHTML;")
wait_for_condition_else_raise(marionette, wait_for_condition, expected2,"return document.getElementById('buttonFlick').innerHTML;")
示例2: _flick_to_image
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
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'])
示例3: _flick_to_image
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
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'])
# Workaround for bug 1161441, the transitionend event is not firing in this
# case with a Marionette flick action, as opposed to a manual flick action
self.marionette.execute_script("""
arguments[0].dispatchEvent(new CustomEvent("transitionend"));
""", [self.current_image_frame])
示例4: _flick_to_month
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
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)
示例5: SelectionCaretsMultipleRangeTest
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
#.........这里部分代码省略.........
return s.replace('\r\n', '\n').replace('\r', '\n')
def test_long_press_to_select_non_selectable_word(self):
'''Testing long press on non selectable field.
We should not select anything when long press on non selectable fields.'''
self.openTestHtml(enabled=True)
halfY = self._nonsel1.size['height'] / 2
long_press_without_contextmenu(self.marionette, self._nonsel1, self._long_press_time, 0, halfY)
sel = SelectionManager(self._nonsel1)
range_count = sel.range_count()
self.assertEqual(range_count, 0)
def test_drag_caret_over_non_selectable_field(self):
'''Testing drag caret over non selectable field.
So that the selected content should exclude non selectable field and
end selection caret should appear in last range's position.'''
self.openTestHtml(enabled=True)
# Select target element and get target caret location
self._long_press_to_select_word(self._sel4, 3)
sel = SelectionManager(self._body)
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
self._long_press_to_select_word(self._sel6, 0)
(_, _), (end_caret2_x, end_caret2_y) = sel.selection_carets_location()
# Select start element
self._long_press_to_select_word(self._sel3, 3)
# Drag end caret to target location
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(self._body, caret2_x, caret2_y, end_caret_x, end_caret_y, 1).perform()
self.assertEqual(self._to_unix_line_ending(sel.selected_content.strip()),
'this 3\nuser can select this')
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(self._body, caret2_x, caret2_y, end_caret2_x, end_caret2_y, 1).perform()
self.assertEqual(self._to_unix_line_ending(sel.selected_content.strip()),
'this 3\nuser can select this 4\nuser can select this 5\nuser')
# Drag first caret to target location
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(self._body, caret1_x, caret1_y, end_caret_x, end_caret_y, 1).perform()
self.assertEqual(self._to_unix_line_ending(sel.selected_content.strip()),
'4\nuser can select this 5\nuser')
def test_drag_caret_to_beginning_of_a_line(self):
'''Bug 1094056
Test caret visibility when caret is dragged to beginning of a line
'''
self.openTestHtml(enabled=True)
# Select the first word in the second line
self._long_press_to_select_word(self._sel2, 0)
sel = SelectionManager(self._body)
(start_caret_x, start_caret_y), (end_caret_x, end_caret_y) = sel.selection_carets_location()
# Select target word in the first line
self._long_press_to_select_word(self._sel1, 2)
# Drag end caret to the beginning of the second line
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(self._body, caret2_x, caret2_y, start_caret_x, start_caret_y).perform()
示例6: AccessibleCaretCursorModeTestCase
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
class AccessibleCaretCursorModeTestCase(MarionetteTestCase):
'''Test cases for AccessibleCaret under cursor mode.
We call the blinking cursor (nsCaret) as cursor, and call AccessibleCaret as
caret for short.
'''
# Element IDs.
_input_id = 'input'
_input_padding_id = 'input-padding'
_textarea_id = 'textarea'
_textarea_one_line_id = 'textarea-one-line'
_contenteditable_id = 'contenteditable'
# Test html files.
_cursor_html = 'test_carets_cursor.html'
def setUp(self):
# Code to execute before every test is running.
super(AccessibleCaretCursorModeTestCase, self).setUp()
self.caret_tested_pref = 'layout.accessiblecaret.enabled'
self.caret_timeout_ms_pref = 'layout.accessiblecaret.timeout_ms'
self.hide_carets_for_mouse = 'layout.accessiblecaret.hide_carets_for_mouse_input'
self.prefs = {
self.caret_tested_pref: True,
self.caret_timeout_ms_pref: 0,
self.hide_carets_for_mouse: False,
}
self.marionette.set_prefs(self.prefs)
self.actions = Actions(self.marionette)
def open_test_html(self, test_html):
self.marionette.navigate(self.marionette.absolute_url(test_html))
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
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)
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
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)
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
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()
#.........这里部分代码省略.........
示例7: CommonCaretsTestCase
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
#.........这里部分代码省略.........
def _test_long_press_to_select_a_word(self, el, assertFunc):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 2, "Expect at least two words in the content.")
target_content = words[0]
# Goal: Select the first word.
self.long_press_on_word(el, 0)
# Ignore extra spaces selected after the word.
assertFunc(target_content, sel.selected_content)
def _test_move_selection_carets(self, el, assertFunc):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, "Expect at least one word in the content.")
# Goal: Select all text after the first word.
target_content = original_content[len(words[0]) :]
# Get the location of the selection carets at the end of the content for
# later use.
el.tap()
sel.select_all()
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
self.long_press_on_word(el, 0)
# Move the right caret to the end of the content.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(el, caret2_x, caret2_y, end_caret_x, end_caret_y).perform()
# Move the left caret to the previous position of the right caret.
self.actions.flick(el, caret1_x, caret1_y, caret2_x, caret2_y).perform()
assertFunc(target_content, sel.selected_content)
def _test_minimum_select_one_character(self, el, assertFunc, x=None, y=None):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, "Expect at least one word in the content.")
# Get the location of the selection carets at the end of the content for
# later use.
sel.select_all()
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
el.tap()
# Goal: Select the first character.
target_content = original_content[0]
if x and y:
# If we got x and y from the arguments, use it as a hint of the
# location of the first word
pass
else:
x, y = self.word_location(el, 0)
self.long_press_on_location(el, x, y)
# Move the right caret to the end of the content.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(el, caret2_x, caret2_y, end_caret_x, end_caret_y).perform()
示例8: SelectionCaretsTest
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
#.........这里部分代码省略.........
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 2, "Expect at least two words in the content.")
target_content = words[0]
# Goal: Select the first word.
x, y = self._first_word_location(el)
self._long_press_to_select(el, x, y)
# Ignore extra spaces selected after the word.
assertFunc(target_content, sel.selected_content.rstrip())
def _test_move_selection_carets(self, el, assertFunc):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, "Expect at least one word in the content.")
# Goal: Select all text after the first word.
target_content = original_content[len(words[0]) :]
# Get the location of the selection carets at the end of the content for
# later use.
el.tap()
sel.select_all()
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
x, y = self._first_word_location(el)
self._long_press_to_select(el, x, y)
# Move the right caret to the end of the content.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(el, caret2_x, caret2_y, end_caret_x, end_caret_y).perform()
# Move the left caret to the previous position of the right caret.
self.actions.flick(el, caret1_x, caret1_y, caret2_x, caret2_y).perform()
# Ignore extra spaces at the beginning of the content in comparison.
assertFunc(target_content.lstrip(), sel.selected_content.lstrip())
def _test_minimum_select_one_character(self, el, assertFunc, x=None, y=None):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, "Expect at least one word in the content.")
# Get the location of the selection carets at the end of the content for
# later use.
sel.select_all()
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
el.tap()
# Goal: Select the first character.
target_content = original_content[0]
if x and y:
# If we got x and y from the arguments, use it as a hint of the
# location of the first word
pass
else:
x, y = self._first_word_location(el)
self._long_press_to_select(el, x, y)
# Move the right caret to the end of the content.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
示例9: CommonCaretTestCase
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
class CommonCaretTestCase(object):
"""Common test cases for a collapsed selection with a single caret.
To run these test cases, a subclass must inherit from both this class and
MarionetteTestCase.
"""
def setUp(self):
# Code to execute before a test is being run.
super(CommonCaretTestCase, self).setUp()
self.actions = Actions(self.marionette)
def timeout_ms(self):
"Return touch caret expiration time in milliseconds."
return self.marionette.get_pref(self.caret_timeout_ms_pref)
def open_test_html(self):
"Open html for testing and locate elements."
test_html = self.marionette.absolute_url("test_touchcaret.html")
self.marionette.navigate(test_html)
self._input = self.marionette.find_element(By.ID, "input")
self._textarea = self.marionette.find_element(By.ID, "textarea")
self._contenteditable = self.marionette.find_element(By.ID, "contenteditable")
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)
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()
self.actions.key_down(content_to_add).key_up(content_to_add).perform()
assertFunc(target_content, sel.content)
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)
def _test_touch_caret_timeout_by_dragging_it_to_top_left_corner_after_timout(self, el, assertFunc):
sel = SelectionManager(el)
content_to_add = "!"
non_target_content = content_to_add + sel.content
# Get touch caret expiration time in millisecond, and convert it to second.
timeout = self.timeout_ms() / 1000.0
#.........这里部分代码省略.........
示例10: CommonCaretsTestCase2
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
#.........这里部分代码省略.........
return s.replace('\r\n', '\n').replace('\r', '\n')
def test_long_press_to_select_non_selectable_word(self):
'''Testing long press on non selectable field.
We should not select anything when long press on non selectable fields.'''
self.open_test_html()
halfY = self._nonsel1.size['height'] / 2
long_press_without_contextmenu(self.marionette, self._nonsel1, self._long_press_time, 0, halfY)
sel = SelectionManager(self._nonsel1)
range_count = sel.range_count()
self.assertEqual(range_count, 0)
def test_drag_caret_over_non_selectable_field(self):
'''Testing drag caret over non selectable field.
So that the selected content should exclude non selectable field and
end selection caret should appear in last range's position.'''
self.open_test_html()
# Select target element and get target caret location
self._long_press_to_select_word(self._sel4, 3)
sel = SelectionManager(self._body)
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
self._long_press_to_select_word(self._sel6, 0)
(_, _), (end_caret2_x, end_caret2_y) = sel.selection_carets_location()
# Select start element
self._long_press_to_select_word(self._sel3, 3)
# Drag end caret to target location
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(self._body, caret2_x, caret2_y, end_caret_x, end_caret_y, 1).perform()
self.assertEqual(self._to_unix_line_ending(sel.selected_content.strip()),
'this 3\nuser can select this')
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(self._body, caret2_x, caret2_y, end_caret2_x, end_caret2_y, 1).perform()
self.assertEqual(self._to_unix_line_ending(sel.selected_content.strip()),
'this 3\nuser can select this 4\nuser can select this 5\nuser')
# Drag first caret to target location
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(self._body, caret1_x, caret1_y, end_caret_x, end_caret_y, 1).perform()
self.assertEqual(self._to_unix_line_ending(sel.selected_content.strip()),
'4\nuser can select this 5\nuser')
def test_drag_caret_to_beginning_of_a_line(self):
'''Bug 1094056
Test caret visibility when caret is dragged to beginning of a line
'''
self.open_test_html()
# Select the first word in the second line
self._long_press_to_select_word(self._sel2, 0)
sel = SelectionManager(self._body)
(start_caret_x, start_caret_y), (end_caret_x, end_caret_y) = sel.selection_carets_location()
# Select target word in the first line
self._long_press_to_select_word(self._sel1, 2)
# Drag end caret to the beginning of the second line
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(self._body, caret2_x, caret2_y, start_caret_x, start_caret_y).perform()
示例11: Loop
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
#.........这里部分代码省略.........
def wizard_or_login(self):
""" Checks if we have to skip the Wizard, log in, or if we're already at the main screen of Loop
For the first two scenarios, it returns True.
If we are already inside Loop, it returns False.
"""
# TODO: switch try-except code -> first check login instead of wizard
# see if it works, when the wizard is first
try:
self.parent.wait_for_element_displayed(*DOM.Loop.wizard_header)
self.UTILS.reporting.logResult('info', '[wizard_or_login] Wizard')
self.skip_wizard()
return True
except:
self.UTILS.reporting.logResult('info', '[wizard_or_login] Login')
try:
self.parent.wait_for_element_displayed(*DOM.Loop.wizard_login)
return True
except:
self.UTILS.reporting.logResult('info', '[wizard_or_login] Loop')
try:
self.parent.wait_for_element_displayed(*DOM.Loop.app_header)
return False
except:
self.UTILS.test.test(False, "Ooops. Something went wrong", True)
def get_wizard_steps(self):
""" Returns the number of steps of the wizard
"""
return len(self.marionette.find_elements(*DOM.Loop.wizard_slideshow_step))
def skip_wizard(self):
""" Skips first time use wizard by flicking the screen
"""
time.sleep(1)
wizard_steps = self.get_wizard_steps()
current_frame = self.apps.displayed_app.frame
x_start = current_frame.size['width'] // 2
x_end = x_start // 4
y_start = current_frame.size['height'] // 2
for i in range(wizard_steps):
self.actions.flick(current_frame, x_start, y_start, x_end, y_start, duration=600).perform()
time.sleep(1)
self.marionette.switch_to_frame(self.apps.displayed_app.frame_id)
self.parent.wait_for_element_displayed(DOM.Loop.wizard_login[0], DOM.Loop.wizard_login[1], timeout=10)
def firefox_login(self, email, password, is_wrong=False):
""" Logs in using Firefox account
"""
self.tap_on_firefox_login_button()
self.UTILS.iframe.switchToFrame(*DOM.Loop.ffox_account_frame_locator)
self.parent.wait_for_element_displayed(
DOM.Loop.ffox_account_login_title[0], DOM.Loop.ffox_account_login_title[1], timeout=20)
self._fill_fxa_field(DOM.Loop.ffox_account_login_mail, email)
self._fill_fxa_field(DOM.Loop.ffox_account_login_pass, password)
if not is_wrong:
done_btn = self.marionette.find_element(*DOM.Loop.ffox_account_login_done)
done_btn.tap()
示例12: Calendar
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
class Calendar(object):
def __init__(self, parent):
self.apps = parent.apps
self.data_layer = parent.data_layer
self.parent = parent
self.marionette = parent.marionette
self.UTILS = parent.UTILS
self.actions = Actions(self.marionette)
def launch(self):
self.app = self.apps.launch(self.__class__.__name__)
self.UTILS.element.waitForNotElements(DOM.GLOBAL.loading_overlay, self.__class__.__name__ + " app - loading overlay")
return self.app
def moveDayViewBy(self, num):
"""
Switches to week view, then moves 'p_num' weeks in the future or past (if the p_num is
positive or negative) relative to today.
"""
self.UTILS.reporting.logResult("info", "<b>Adjusting day view by {} screens ...</b>".format(num))
self.setView("day")
self.setView("today")
if num == 0:
return
"""
Set the y-coordinate offset, depending on which
direction we need to flick the display.
"""
numMoves = num
if numMoves > 0:
_moveEl = 1
else:
_moveEl = 2
numMoves = numMoves * -1
# Now move to the desired screen.
for i in range(numMoves):
# Flick the screen to move it (tricky to find the element we can flick!).
_el = self.marionette.find_elements(*DOM.Calendar.dview_events)
_num = 0
for i in range(len(_el)):
if _el[i].is_displayed():
_num = i
break
x_pos1 = 0
x_pos2 = 0
if _moveEl == 1:
x_pos1 = _el[_num].size["width"]
if _moveEl == 2:
x_pos2 = _el[_num].size["width"]
self.actions.flick(_el[_num], x_pos1, 0, x_pos2, 0).perform()
time.sleep(0.3)
# Check this is the expected day.
_new_epoch = int(time.time()) + (num * 24 * 60 * 60)
_new_now = self.UTILS.date_and_time.getDateTimeFromEpochSecs(_new_epoch)
_expected_str = "{} {}, {}".format(_new_now.month_name[:3], _new_now.mday, _new_now.day_name)
x = self.UTILS.element.getElement(DOM.Calendar.current_view_header, "Current view header")
self.UTILS.test.test(x.text == _expected_str, "Header is '<b>%s</b>' (it was '%s')." % (_expected_str, x.text))
x = self.UTILS.debug.screenShotOnErr()
self.UTILS.reporting.logResult("info", "Day view screen after moving {} pages: ".format(num), x)
def getEventPreview(self, p_view, p_hour24, p_title, p_location=False):
"""
Return object for an event in month / week or day view.
The tag identifiers aren't consistent, so set them here.
<type>: (<event preview identifier>, <event title identifier>)
"""
event_view = {
"month": (DOM.Calendar.view_events_block_m % p_hour24, DOM.Calendar.view_events_title_month),
"week": (DOM.Calendar.view_events_block_w % p_hour24, DOM.Calendar.view_events_title_week),
"day": (DOM.Calendar.view_events_block_d % p_hour24, DOM.Calendar.view_events_title_day)
}
viewStr = event_view[p_view]
"""
Switch to the desired view.
For the life of me I can't get 'wait_for_element' ... to work in day view, so I'm
just waiting a few seconds then checking with .is_displayed() instead.
"""
self.setView(p_view)
time.sleep(2)
# Start by getting the parent element objects, which could contain event details.
event_objects = self.UTILS.element.getElements(('xpath', viewStr[0]), "'" + p_view + "' event details list",
False, 20, False)
if not event_objects:
return False
if len(event_objects) <= 0:
return False
for event_object in event_objects:
#.........这里部分代码省略.........
示例13: CommonCaretsTestCase
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
#.........这里部分代码省略.........
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 2, 'Expect at least two words in the content.')
target_content = words[0]
# Goal: Select the first word.
x, y = self._first_word_location(el)
self._long_press_to_select(el, x, y)
# Ignore extra spaces selected after the word.
assertFunc(target_content, sel.selected_content.rstrip())
def _test_move_selection_carets(self, el, assertFunc):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, 'Expect at least one word in the content.')
# Goal: Select all text after the first word.
target_content = original_content[len(words[0]):]
# Get the location of the selection carets at the end of the content for
# later use.
el.tap()
sel.select_all()
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
x, y = self._first_word_location(el)
self._long_press_to_select(el, x, y)
# Move the right caret to the end of the content.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(el, caret2_x, caret2_y, end_caret_x, end_caret_y).perform()
# Move the left caret to the previous position of the right caret.
self.actions.flick(el, caret1_x, caret1_y, caret2_x, caret2_y).perform()
# Ignore extra spaces at the beginning of the content in comparison.
assertFunc(target_content.lstrip(), sel.selected_content.lstrip())
def _test_minimum_select_one_character(self, el, assertFunc,
x=None, y=None):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, 'Expect at least one word in the content.')
# Get the location of the selection carets at the end of the content for
# later use.
sel.select_all()
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
el.tap()
# Goal: Select the first character.
target_content = original_content[0]
if x and y:
# If we got x and y from the arguments, use it as a hint of the
# location of the first word
pass
else:
x, y = self._first_word_location(el)
self._long_press_to_select(el, x, y)
# Move the right caret to the end of the content.
示例14: AccessibleCaretSelectionModeTestCase
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
#.........这里部分代码省略.........
# Goal: Select the first word.
self.long_press_on_word(el, 0)
# Ignore extra spaces selected after the word.
self.assertEqual(target_content, sel.selected_content)
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
@parameterized(_content_id, el_id=_content_id)
def test_drag_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.")
# Goal: Select all text after the first word.
target_content = 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 second caret to the end of the content.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.carets_location()
self.actions.flick(el, caret2_x, caret2_y, end_caret_x, end_caret_y).perform()
# Drag the first caret to the previous position of the second caret.
self.actions.flick(el, caret1_x, caret1_y, caret2_x, caret2_y).perform()
self.assertEqual(target_content, sel.selected_content)
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
@parameterized(_content_id, el_id=_content_id)
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.
示例15: CommonCaretTestCase
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import flick [as 别名]
class CommonCaretTestCase(object):
'''Common test cases for a collapsed selection with a single caret.
To run these test cases, a subclass must inherit from both this class and
MarionetteTestCase.
'''
_input_selector = (By.ID, 'input')
_textarea_selector = (By.ID, 'textarea')
_contenteditable_selector = (By.ID, 'contenteditable')
def setUp(self):
# Code to execute before a test is being run.
super(CommonCaretTestCase, self).setUp()
self.actions = Actions(self.marionette)
# The caret to be tested.
self.caret_tested_pref = None
# The caret to be disabled in this test suite.
self.caret_disabled_pref = None
self.caret_timeout_ms_pref = None
def set_pref(self, pref_name, value):
'''Set a preference to value.
For example:
>>> set_pref('layout.accessiblecaret.enabled', True)
'''
pref_name = repr(pref_name)
if isinstance(value, bool):
value = 'true' if value else 'false'
func = 'setBoolPref'
elif isinstance(value, int):
value = str(value)
func = 'setIntPref'
else:
value = repr(value)
func = 'setCharPref'
with self.marionette.using_context('chrome'):
script = 'Services.prefs.%s(%s, %s)' % (func, pref_name, value)
self.marionette.execute_script(script)
def timeout_ms(self):
'Return touch caret expiration time in milliseconds.'
with self.marionette.using_context('chrome'):
return self.marionette.execute_script(
'return Services.prefs.getIntPref("%s");' % self.caret_timeout_ms_pref)
def open_test_html(self, enabled=True, timeout_ms=0):
'''Open html for testing and locate elements, enable/disable touch caret, and
set touch caret expiration time in milliseconds).
'''
self.set_pref(self.caret_tested_pref, enabled)
self.set_pref(self.caret_disabled_pref, False)
self.set_pref(self.caret_timeout_ms_pref, timeout_ms)
test_html = self.marionette.absolute_url('test_touchcaret.html')
self.marionette.navigate(test_html)
self._input = self.marionette.find_element(*self._input_selector)
self._textarea = self.marionette.find_element(*self._textarea_selector)
self._contenteditable = self.marionette.find_element(*self._contenteditable_selector)
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()
el.send_keys(content_to_add)
assertFunc(target_content, sel.content)
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())
#.........这里部分代码省略.........