OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 import time | 6 import time |
7 import urlparse | 7 import urlparse |
8 | 8 |
9 from telemetry.internal.actions.drag import DragAction | 9 from telemetry.internal.actions.drag import DragAction |
10 from telemetry.internal.actions.javascript_click import ClickElementAction | 10 from telemetry.internal.actions.javascript_click import ClickElementAction |
11 from telemetry.internal.actions.key_event import KeyPressAction | 11 from telemetry.internal.actions.key_event import KeyPressAction |
12 from telemetry.internal.actions.load_media import LoadMediaAction | 12 from telemetry.internal.actions.load_media import LoadMediaAction |
13 from telemetry.internal.actions.loop import LoopAction | 13 from telemetry.internal.actions.loop import LoopAction |
14 from telemetry.internal.actions.mouse_click import MouseClickAction | 14 from telemetry.internal.actions.mouse_click import MouseClickAction |
15 from telemetry.internal.actions.navigate import NavigateAction | 15 from telemetry.internal.actions.navigate import NavigateAction |
16 from telemetry.internal.actions.page_action import GESTURE_SOURCE_DEFAULT | 16 from telemetry.internal.actions.page_action import GESTURE_SOURCE_DEFAULT |
17 from telemetry.internal.actions.page_action import SUPPORTED_GESTURE_SOURCES | 17 from telemetry.internal.actions.page_action import SUPPORTED_GESTURE_SOURCES |
18 from telemetry.internal.actions.pinch import PinchAction | 18 from telemetry.internal.actions.pinch import PinchAction |
19 from telemetry.internal.actions.play import PlayAction | 19 from telemetry.internal.actions.play import PlayAction |
20 from telemetry.internal.actions.repaint_continuously import ( | 20 from telemetry.internal.actions.repaint_continuously import ( |
21 RepaintContinuouslyAction) | 21 RepaintContinuouslyAction) |
22 from telemetry.internal.actions.repeatable_scroll import RepeatableScrollAction | 22 from telemetry.internal.actions.repeatable_scroll import RepeatableScrollAction |
23 from telemetry.internal.actions.scroll import ScrollAction | 23 from telemetry.internal.actions.scroll import ScrollAction |
24 from telemetry.internal.actions.scroll_bounce import ScrollBounceAction | 24 from telemetry.internal.actions.scroll_bounce import ScrollBounceAction |
25 from telemetry.internal.actions.scroll_to_element import ScrollToElementAction | |
25 from telemetry.internal.actions.seek import SeekAction | 26 from telemetry.internal.actions.seek import SeekAction |
26 from telemetry.internal.actions.swipe import SwipeAction | 27 from telemetry.internal.actions.swipe import SwipeAction |
27 from telemetry.internal.actions.tap import TapAction | 28 from telemetry.internal.actions.tap import TapAction |
28 from telemetry.internal.actions.wait import WaitForElementAction | 29 from telemetry.internal.actions.wait import WaitForElementAction |
29 from telemetry.web_perf import timeline_interaction_record | 30 from telemetry.web_perf import timeline_interaction_record |
30 | 31 |
31 | 32 |
32 _DUMP_WAIT_TIME = 3 | 33 _DUMP_WAIT_TIME = 3 |
33 | 34 |
34 | 35 |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 synthetic_gesture_source: the source input device type for the | 387 synthetic_gesture_source: the source input device type for the |
387 synthetic gesture: 'DEFAULT', 'TOUCH' or 'MOUSE'. | 388 synthetic gesture: 'DEFAULT', 'TOUCH' or 'MOUSE'. |
388 """ | 389 """ |
389 assert synthetic_gesture_source in SUPPORTED_GESTURE_SOURCES | 390 assert synthetic_gesture_source in SUPPORTED_GESTURE_SOURCES |
390 self._RunAction(ScrollAction( | 391 self._RunAction(ScrollAction( |
391 left_start_ratio=left_start_ratio, top_start_ratio=top_start_ratio, | 392 left_start_ratio=left_start_ratio, top_start_ratio=top_start_ratio, |
392 direction=direction, distance=distance, distance_expr=distance_expr, | 393 direction=direction, distance=distance, distance_expr=distance_expr, |
393 speed_in_pixels_per_second=speed_in_pixels_per_second, | 394 speed_in_pixels_per_second=speed_in_pixels_per_second, |
394 use_touch=use_touch, synthetic_gesture_source=synthetic_gesture_source)) | 395 use_touch=use_touch, synthetic_gesture_source=synthetic_gesture_source)) |
395 | 396 |
397 def ScrollPageToElement(self, selector=None, element_function=None): | |
398 """Perform scroll gesture on page until an element is in view. | |
399 | |
400 Args: | |
401 selector: A CSS selector describing the element. | |
402 text: The element must contains this exact text. | |
charliea (OOO until 10-5)
2016/10/14 03:34:28
|text| isn't an arg here. bad c/p?
rnephew (Reviews Here)
2016/10/14 17:57:17
Done.
| |
403 element_function: A JavaScript function (as string) that is used | |
404 to retrieve the element. For example: | |
405 'function() { return foo.element; }'. | |
406 """ | |
407 self._RunAction(ScrollToElementAction( | |
408 selector=selector, element_function=element_function)) | |
409 | |
396 def RepeatableBrowserDrivenScroll(self, x_scroll_distance_ratio=0.0, | 410 def RepeatableBrowserDrivenScroll(self, x_scroll_distance_ratio=0.0, |
397 y_scroll_distance_ratio=0.5, | 411 y_scroll_distance_ratio=0.5, |
398 repeat_count=0, | 412 repeat_count=0, |
399 repeat_delay_ms=250, | 413 repeat_delay_ms=250, |
400 timeout=60, | 414 timeout=60, |
401 prevent_fling=None, | 415 prevent_fling=None, |
402 speed=None): | 416 speed=None): |
403 """Perform a browser driven repeatable scroll gesture. | 417 """Perform a browser driven repeatable scroll gesture. |
404 | 418 |
405 The scroll gesture is driven from the browser, this is useful because the | 419 The scroll gesture is driven from the browser, this is useful because the |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
781 timeline_interaction_record.GetJavaScriptMarker( | 795 timeline_interaction_record.GetJavaScriptMarker( |
782 self._label, self._flags)) | 796 self._label, self._flags)) |
783 | 797 |
784 def End(self): | 798 def End(self): |
785 assert self._started | 799 assert self._started |
786 self._started = False | 800 self._started = False |
787 self._action_runner.ExecuteJavaScript( | 801 self._action_runner.ExecuteJavaScript( |
788 'console.timeEnd("%s");' % | 802 'console.timeEnd("%s");' % |
789 timeline_interaction_record.GetJavaScriptMarker( | 803 timeline_interaction_record.GetJavaScriptMarker( |
790 self._label, self._flags)) | 804 self._label, self._flags)) |
OLD | NEW |