Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: telemetry/telemetry/internal/actions/action_runner.py

Issue 2421433003: Add ScrollPageToElement to action_runner. (Closed)
Patch Set: Add ScrollPageToElement to action_runner. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | telemetry/telemetry/internal/actions/action_runner_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/internal/actions/action_runner.py
diff --git a/telemetry/telemetry/internal/actions/action_runner.py b/telemetry/telemetry/internal/actions/action_runner.py
index 28c00c883d4d13ac595da0c1216961826834c0be..a2a647cf70facea938f25efd522aa6ae0aba4714 100644
--- a/telemetry/telemetry/internal/actions/action_runner.py
+++ b/telemetry/telemetry/internal/actions/action_runner.py
@@ -22,6 +22,7 @@ from telemetry.internal.actions.repaint_continuously import (
from telemetry.internal.actions.repeatable_scroll import RepeatableScrollAction
from telemetry.internal.actions.scroll import ScrollAction
from telemetry.internal.actions.scroll_bounce import ScrollBounceAction
+from telemetry.internal.actions.scroll_to_element import ScrollToElementAction
from telemetry.internal.actions.seek import SeekAction
from telemetry.internal.actions.swipe import SwipeAction
from telemetry.internal.actions.tap import TapAction
@@ -397,6 +398,21 @@ class ActionRunner(object):
speed_in_pixels_per_second=speed_in_pixels_per_second,
use_touch=use_touch, synthetic_gesture_source=synthetic_gesture_source))
+ def ScrollPageToElement(self, selector=None, element_function=None,
+ speed_in_pixels_per_second=800):
+ """Perform scroll gesture on page until an element is in view.
+
+ Args:
+ selector: A CSS selector describing the element.
+ element_function: A JavaScript function (as string) that is used
+ to retrieve the element. For example:
+ 'function() { return foo.element; }'.
+ speed_in_pixels_per_second: Speed to scroll.
+ """
+ self._RunAction(ScrollToElementAction(
+ selector=selector, element_function=element_function,
+ speed_in_pixels_per_second=speed_in_pixels_per_second))
+
def RepeatableBrowserDrivenScroll(self, x_scroll_distance_ratio=0.0,
y_scroll_distance_ratio=0.5,
repeat_count=0,
« no previous file with comments | « no previous file | telemetry/telemetry/internal/actions/action_runner_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698