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

Side by Side Diff: tools/perf/page_sets/top_10.py

Issue 321563003: Add Wait* API to ActionRunner to wrap over WaitAction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
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 # pylint: disable=W0401,W0614 4 # pylint: disable=W0401,W0614
5 from telemetry.page.actions.all_page_actions import * 5 from telemetry.page.actions.all_page_actions import *
6 from telemetry.page import page as page_module 6 from telemetry.page import page as page_module
7 from telemetry.page import page_set as page_set_module 7 from telemetry.page import page_set as page_set_module
8 8
9 9
10 class SimpleScrollPage(page_module.Page): 10 class SimpleScrollPage(page_module.Page):
11 def __init__(self, url, page_set, credentials='', name=''): 11 def __init__(self, url, page_set, credentials='', name=''):
12 super(SimpleScrollPage, self).__init__(url, page_set=page_set, name=name) 12 super(SimpleScrollPage, self).__init__(url, page_set=page_set, name=name)
13 self.credentials = credentials 13 self.credentials = credentials
14 14
15 def RunSmoothness(self, action_runner): 15 def RunSmoothness(self, action_runner):
16 action_runner.RunAction(ScrollAction()) 16 action_runner.RunAction(ScrollAction())
17 17
18 class Google(SimpleScrollPage): 18 class Google(SimpleScrollPage):
19 def __init__(self, page_set): 19 def __init__(self, page_set):
20 super(Google, self).__init__( 20 super(Google, self).__init__(
21 url='https://www.google.com/#hl=en&q=barack+obama', page_set=page_set) 21 url='https://www.google.com/#hl=en&q=barack+obama', page_set=page_set)
22 22
23 def RunNavigateSteps(self, action_runner): 23 def RunNavigateSteps(self, action_runner):
24 super(Google, self).RunNavigateSteps(action_runner) 24 super(Google, self).RunNavigateSteps(action_runner)
25 action_runner.RunAction(WaitAction( 25 action_runner.WaitForElement(contains_text='Next')
26 {'condition': 'element', 'text': 'Next'}))
27 26
28 27
29 class Gmail(SimpleScrollPage): 28 class Gmail(SimpleScrollPage):
30 def __init__(self, page_set): 29 def __init__(self, page_set):
31 super(Gmail, self).__init__( 30 super(Gmail, self).__init__(
32 url='https://mail.google.com/mail/', 31 url='https://mail.google.com/mail/',
33 page_set=page_set, 32 page_set=page_set,
34 credentials='google') 33 credentials='google')
35 34
36 def RunNavigateSteps(self, action_runner): 35 def RunNavigateSteps(self, action_runner):
(...skipping 11 matching lines...) Expand all
48 credentials='google') 47 credentials='google')
49 48
50 def RunNavigateSteps(self, action_runner): 49 def RunNavigateSteps(self, action_runner):
51 super(GoogleCalendar, self).RunNavigateSteps(action_runner) 50 super(GoogleCalendar, self).RunNavigateSteps(action_runner)
52 action_runner.ExecuteJavaScript(''' 51 action_runner.ExecuteJavaScript('''
53 (function() { var elem = document.createElement("meta"); 52 (function() { var elem = document.createElement("meta");
54 elem.name="viewport"; 53 elem.name="viewport";
55 elem.content="initial-scale=1"; 54 elem.content="initial-scale=1";
56 document.body.appendChild(elem); 55 document.body.appendChild(elem);
57 })();''') 56 })();''')
58 action_runner.RunAction(WaitAction({'seconds' : 2})) 57 action_runner.Wait(2)
59 action_runner.RunAction(WaitAction({ 58 action_runner.WaitForElement('div[class~="navForward"]')
60 'condition' : 'element', 'selector' : 'div[class~="navForward"]'}))
61 59
62 60
63 class Youtube(SimpleScrollPage): 61 class Youtube(SimpleScrollPage):
64 def __init__(self, page_set): 62 def __init__(self, page_set):
65 super(Youtube, self).__init__( 63 super(Youtube, self).__init__(
66 url='http://www.youtube.com', 64 url='http://www.youtube.com',
67 page_set=page_set, 65 page_set=page_set,
68 credentials='google') 66 credentials='google')
69 67
70 def RunNavigateSteps(self, action_runner): 68 def RunNavigateSteps(self, action_runner):
71 super(Youtube, self).RunNavigateSteps(action_runner) 69 super(Youtube, self).RunNavigateSteps(action_runner)
72 action_runner.RunAction(WaitAction({'seconds' : 2})) 70 action_runner.Wait(2)
73 71
74 72
75 class Facebook(SimpleScrollPage): 73 class Facebook(SimpleScrollPage):
76 def __init__(self, page_set): 74 def __init__(self, page_set):
77 super(Facebook, self).__init__( 75 super(Facebook, self).__init__(
78 url='http://www.facebook.com/barackobama', 76 url='http://www.facebook.com/barackobama',
79 page_set=page_set, 77 page_set=page_set,
80 credentials='facebook', 78 credentials='facebook',
81 name='Facebook') 79 name='Facebook')
82 80
83 def RunNavigateSteps(self, action_runner): 81 def RunNavigateSteps(self, action_runner):
84 super(Facebook, self).RunNavigateSteps(action_runner) 82 super(Facebook, self).RunNavigateSteps(action_runner)
85 action_runner.RunAction(WaitAction( 83 action_runner.WaitForElement(contains_text='About')
86 {'condition': 'element', 'text': 'About'}))
87 84
88 85
89 class Top10PageSet(page_set_module.PageSet): 86 class Top10PageSet(page_set_module.PageSet):
90 def __init__(self): 87 def __init__(self):
91 super(Top10PageSet, self).__init__( 88 super(Top10PageSet, self).__init__(
92 description='10 Pages chosen from Alexa top sites', 89 description='10 Pages chosen from Alexa top sites',
93 archive_data_file='data/top_10.json', 90 archive_data_file='data/top_10.json',
94 credentials_path='data/credentials.json', 91 credentials_path='data/credentials.json',
95 user_agent_type='desktop') 92 user_agent_type='desktop')
96 93
(...skipping 20 matching lines...) Expand all
117 self.AddPage(SimpleScrollPage('http://www.amazon.com', self)) 114 self.AddPage(SimpleScrollPage('http://www.amazon.com', self))
118 115
119 # #4 Alexa 116 # #4 Alexa
120 self.AddPage(SimpleScrollPage('http://www.yahoo.com/', self)) 117 self.AddPage(SimpleScrollPage('http://www.yahoo.com/', self))
121 118
122 # #16 Alexa 119 # #16 Alexa
123 self.AddPage(SimpleScrollPage('http://www.bing.com/', self)) 120 self.AddPage(SimpleScrollPage('http://www.bing.com/', self))
124 121
125 # #20 Alexa 122 # #20 Alexa
126 self.AddPage(SimpleScrollPage('http://www.ask.com/', self)) 123 self.AddPage(SimpleScrollPage('http://www.ask.com/', self))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698