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

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

Issue 2421433003: Add ScrollPageToElement to action_runner. (Closed)
Patch Set: scroll element to center instead of top 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
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 4a0584be3cedf5f91ec4798730b269a045b9911d..5fae42702a8bdeb13128130ca0ac9836191cb109 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
@@ -393,6 +394,19 @@ 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):
+ """Perform scroll gesture on page until an element is in view.
+
+ Args:
+ selector: A CSS selector describing the element.
+ 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.
+ element_function: A JavaScript function (as string) that is used
+ to retrieve the element. For example:
+ 'function() { return foo.element; }'.
+ """
+ self._RunAction(ScrollToElementAction(
+ selector=selector, element_function=element_function))
+
def RepeatableBrowserDrivenScroll(self, x_scroll_distance_ratio=0.0,
y_scroll_distance_ratio=0.5,
repeat_count=0,

Powered by Google App Engine
This is Rietveld 408576698