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

Unified Diff: tools/telemetry/telemetry/page/actions/action_runner.py

Issue 337643002: Add SwipePage/SwipeElement API to action_runner, wrapping over (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Guard test execution so that test doesn't fail in browser that doesn't support touch. Created 6 years, 6 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 | « tools/perf/page_sets/polymer.py ('k') | tools/telemetry/telemetry/page/actions/action_runner_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/page/actions/action_runner.py
diff --git a/tools/telemetry/telemetry/page/actions/action_runner.py b/tools/telemetry/telemetry/page/actions/action_runner.py
index aff25bcfce88976353614d01accc4bef251ab76b..0389e2254c21e86b9dd5d7991d53905fb41c25de 100644
--- a/tools/telemetry/telemetry/page/actions/action_runner.py
+++ b/tools/telemetry/telemetry/page/actions/action_runner.py
@@ -4,6 +4,7 @@
from telemetry.page.actions.javascript_click import ClickElementAction
from telemetry.page.actions.navigate import NavigateAction
+from telemetry.page.actions.swipe import SwipeAction
from telemetry.page.actions.tap import TapAction
from telemetry.page.actions.wait import WaitAction
from telemetry.web_perf import timeline_interaction_record as tir_module
@@ -193,6 +194,53 @@ class ActionRunner(object):
self.RunAction(ClickElementAction(
selector=selector, text=text, element_function=element_function))
+ def SwipePage(self, left_start_ratio=0.5, top_start_ratio=0.5,
+ direction='left', distance=100, speed=800):
+ """Perform swipe gesture on the page.
+
+ Args:
+ left_start_ratio: The horizontal starting coordinate of the
+ gesture, as a ratio of the visible bounding rectangle for
+ document.body.
+ top_start_ratio: The vertical starting coordinate of the
+ gesture, as a ratio of the visible bounding rectangle for
+ document.body.
+ direction: The direction of swipe, either 'left', 'right',
+ 'up', or 'down'
+ distance: The distance to swipe (in pixel).
+ speed: The speed of the gesture.
+ """
+ self.RunAction(SwipeAction(
+ left_start_ratio=left_start_ratio, top_start_ratio=top_start_ratio,
+ direction=direction, distance=distance, speed=speed))
+
+ def SwipeElement(self, selector=None, text=None, element_function=None,
+ left_start_ratio=0.5, top_start_ratio=0.5,
+ direction='left', distance=100, speed=800):
+ """Perform swipe gesture on the element.
+
+ Args:
+ selector: A CSS selector describing the element.
+ text: The element must contains this exact text.
+ element_function: A JavaScript function (as string) that is used
+ to retrieve the element. For example:
+ 'function() { return foo.element; }'.
+ left_start_ratio: The horizontal starting coordinate of the
+ gesture, as a ratio of the visible bounding rectangle for
+ the element.
+ top_start_ratio: The vertical starting coordinate of the
+ gesture, as a ratio of the visible bounding rectangle for
+ the element.
+ direction: The direction of swipe, either 'left', 'right',
+ 'up', or 'down'
+ distance: The distance to swipe (in pixel).
+ speed: The speed of the gesture.
+ """
+ self.RunAction(SwipeAction(
+ selector=selector, text=text, element_function=element_function,
+ left_start_ratio=left_start_ratio, top_start_ratio=top_start_ratio,
+ direction=direction, distance=distance, speed=speed))
+
class Interaction(object):
« no previous file with comments | « tools/perf/page_sets/polymer.py ('k') | tools/telemetry/telemetry/page/actions/action_runner_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698