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 # 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(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): |
37 super(Gmail, self).RunNavigateSteps(action_runner) | 36 super(Gmail, self).RunNavigateSteps(action_runner) |
38 action_runner.RunAction(WaitAction( | 37 action_runner.WaitForJavaScriptCondition( |
39 {'javascript' : 'window.gmonkey !== undefined &&' | 38 'window.gmonkey !== undefined &&' |
40 'document.getElementById("gb") !== null'})) | 39 'document.getElementById("gb") !== null') |
41 | 40 |
42 | 41 |
43 class GoogleCalendar(SimpleScrollPage): | 42 class GoogleCalendar(SimpleScrollPage): |
44 def __init__(self, page_set): | 43 def __init__(self, page_set): |
45 super(GoogleCalendar, self).__init__( | 44 super(GoogleCalendar, self).__init__( |
46 url='https://www.google.com/calendar/', | 45 url='https://www.google.com/calendar/', |
47 page_set=page_set, | 46 page_set=page_set, |
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(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 """10 Pages chosen from Alexa top sites""" | 87 """10 Pages chosen from Alexa top sites""" |
91 | 88 |
92 def __init__(self): | 89 def __init__(self): |
93 super(Top10PageSet, self).__init__( | 90 super(Top10PageSet, self).__init__( |
94 archive_data_file='data/top_10.json', | 91 archive_data_file='data/top_10.json', |
95 credentials_path='data/credentials.json', | 92 credentials_path='data/credentials.json', |
96 user_agent_type='desktop') | 93 user_agent_type='desktop') |
(...skipping 21 matching lines...) Expand all Loading... |
118 self.AddPage(SimpleScrollPage('http://www.amazon.com', self)) | 115 self.AddPage(SimpleScrollPage('http://www.amazon.com', self)) |
119 | 116 |
120 # #4 Alexa | 117 # #4 Alexa |
121 self.AddPage(SimpleScrollPage('http://www.yahoo.com/', self)) | 118 self.AddPage(SimpleScrollPage('http://www.yahoo.com/', self)) |
122 | 119 |
123 # #16 Alexa | 120 # #16 Alexa |
124 self.AddPage(SimpleScrollPage('http://www.bing.com/', self)) | 121 self.AddPage(SimpleScrollPage('http://www.bing.com/', self)) |
125 | 122 |
126 # #20 Alexa | 123 # #20 Alexa |
127 self.AddPage(SimpleScrollPage('http://www.ask.com/', self)) | 124 self.AddPage(SimpleScrollPage('http://www.ask.com/', self)) |
OLD | NEW |