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 CalendarForwardBackwardPage(page_module.Page): | 10 class CalendarForwardBackwardPage(page_module.Page): |
11 | 11 |
12 """ Why: Click forward(4x) and backwards(4x) repeatedly """ | 12 """ Why: Click forward(4x) and backwards(4x) repeatedly """ |
13 | 13 |
14 def __init__(self, page_set): | 14 def __init__(self, page_set): |
15 super(CalendarForwardBackwardPage, self).__init__( | 15 super(CalendarForwardBackwardPage, self).__init__( |
16 url='https://www.google.com/calendar/', | 16 url='https://www.google.com/calendar/', |
17 page_set=page_set, | 17 page_set=page_set, |
18 name='calendar_forward_backward') | 18 name='calendar_forward_backward') |
19 self.credentials_path = 'data/credentials.json' | 19 self.credentials_path = 'data/credentials.json' |
20 self.credentials = 'google' | 20 self.credentials = 'google' |
21 self.user_agent_type = 'desktop' | 21 self.user_agent_type = 'desktop' |
22 self.archive_data_file = 'data/calendar_forward_backward.json' | 22 self.archive_data_file = 'data/calendar_forward_backward.json' |
23 | 23 |
24 def RunNavigateSteps(self, action_runner): | 24 def RunNavigateSteps(self, action_runner): |
25 action_runner.NavigateToPage(self) | 25 action_runner.NavigateToPage(self) |
26 action_runner.RunAction(WaitAction( | 26 action_runner.Wait(2) |
27 { | 27 action_runner.WaitForElement('div[class~="navForward"]') |
28 'seconds': 2 | |
29 })) | |
30 action_runner.RunAction(WaitAction( | |
31 { | |
32 'condition': 'element', | |
33 'selector': 'div[class~="navForward"]' | |
34 })) | |
35 action_runner.ExecuteJavaScript(''' | 28 action_runner.ExecuteJavaScript(''' |
36 (function() { | 29 (function() { |
37 var elem = document.createElement('meta'); | 30 var elem = document.createElement('meta'); |
38 elem.name='viewport'; | 31 elem.name='viewport'; |
39 elem.content='initial-scale=1'; | 32 elem.content='initial-scale=1'; |
40 document.body.appendChild(elem); | 33 document.body.appendChild(elem); |
41 })();''') | 34 })();''') |
42 | 35 |
43 def RunEndure(self, action_runner): | 36 def RunEndure(self, action_runner): |
44 action_runner.RunAction(ClickElementAction( | 37 action_runner.RunAction(ClickElementAction( |
45 { | 38 { |
46 'selector': 'div[class~="navForward"]' | 39 'selector': 'div[class~="navForward"]' |
47 })) | 40 })) |
48 action_runner.RunAction(WaitAction( | 41 action_runner.Wait(2) |
49 { | 42 action_runner.WaitForElement('div[class~="navForward"]') |
50 'seconds': 2 | |
51 })) | |
52 action_runner.RunAction(WaitAction( | |
53 { | |
54 'condition': 'element', | |
55 'selector': 'div[class~="navForward"]' | |
56 })) | |
57 action_runner.RunAction(ClickElementAction( | 43 action_runner.RunAction(ClickElementAction( |
58 { | 44 { |
59 'selector': 'div[class~="navForward"]' | 45 'selector': 'div[class~="navForward"]' |
60 })) | 46 })) |
61 action_runner.RunAction(WaitAction( | 47 action_runner.Wait(2) |
62 { | 48 action_runner.WaitForElement('div[class~="navForward"]') |
63 'seconds': 2 | |
64 })) | |
65 action_runner.RunAction(WaitAction( | |
66 { | |
67 'condition': 'element', | |
68 'selector': 'div[class~="navForward"]' | |
69 })) | |
70 action_runner.RunAction(ClickElementAction( | 49 action_runner.RunAction(ClickElementAction( |
71 { | 50 { |
72 'selector': 'div[class~="navForward"]' | 51 'selector': 'div[class~="navForward"]' |
73 })) | 52 })) |
74 action_runner.RunAction(WaitAction( | 53 action_runner.Wait(2) |
75 { | 54 action_runner.WaitForElement('div[class~="navForward"]') |
76 'seconds': 2 | |
77 })) | |
78 action_runner.RunAction(WaitAction( | |
79 { | |
80 'condition': 'element', | |
81 'selector': 'div[class~="navForward"]' | |
82 })) | |
83 action_runner.RunAction(ClickElementAction( | 55 action_runner.RunAction(ClickElementAction( |
84 { | 56 { |
85 'selector': 'div[class~="navForward"]' | 57 'selector': 'div[class~="navForward"]' |
86 })) | 58 })) |
87 action_runner.RunAction(WaitAction( | 59 action_runner.Wait(2) |
88 { | 60 action_runner.WaitForElement('div[class~="navBack"]') |
89 'seconds': 2 | |
90 })) | |
91 action_runner.RunAction(WaitAction( | |
92 { | |
93 'condition': 'element', | |
94 'selector': 'div[class~="navBack"]' | |
95 })) | |
96 action_runner.RunAction(ClickElementAction( | 61 action_runner.RunAction(ClickElementAction( |
97 { | 62 { |
98 'selector': 'div[class~="navBack"]' | 63 'selector': 'div[class~="navBack"]' |
99 })) | 64 })) |
100 action_runner.RunAction(WaitAction( | 65 action_runner.Wait(2) |
101 { | 66 action_runner.WaitForElement('div[class~="navBack"]') |
102 'seconds': 2 | |
103 })) | |
104 action_runner.RunAction(WaitAction( | |
105 { | |
106 'condition': 'element', | |
107 'selector': 'div[class~="navBack"]' | |
108 })) | |
109 action_runner.RunAction(ClickElementAction( | 67 action_runner.RunAction(ClickElementAction( |
110 { | 68 { |
111 'selector': 'div[class~="navBack"]' | 69 'selector': 'div[class~="navBack"]' |
112 })) | 70 })) |
113 action_runner.RunAction(WaitAction( | 71 action_runner.Wait(2) |
114 { | 72 action_runner.WaitForElement('div[class~="navBack"]') |
115 'seconds': 2 | |
116 })) | |
117 action_runner.RunAction(WaitAction( | |
118 { | |
119 'condition': 'element', | |
120 'selector': 'div[class~="navBack"]' | |
121 })) | |
122 action_runner.RunAction(ClickElementAction( | 73 action_runner.RunAction(ClickElementAction( |
123 { | 74 { |
124 'selector': 'div[class~="navBack"]' | 75 'selector': 'div[class~="navBack"]' |
125 })) | 76 })) |
126 action_runner.RunAction(WaitAction( | 77 action_runner.Wait(2) |
127 { | 78 action_runner.WaitForElement('div[class~="navBack"]') |
128 'seconds': 2 | |
129 })) | |
130 action_runner.RunAction(WaitAction( | |
131 { | |
132 'condition': 'element', | |
133 'selector': 'div[class~="navBack"]' | |
134 })) | |
135 action_runner.RunAction(ClickElementAction( | 79 action_runner.RunAction(ClickElementAction( |
136 { | 80 { |
137 'selector': 'div[class~="navBack"]' | 81 'selector': 'div[class~="navBack"]' |
138 })) | 82 })) |
139 action_runner.RunAction(WaitAction( | 83 action_runner.Wait(2) |
140 { | 84 action_runner.WaitForElement('div[class~="navForward"]') |
141 'seconds': 2 | |
142 })) | |
143 action_runner.RunAction(WaitAction( | |
144 { | |
145 'condition': 'element', | |
146 'selector': 'div[class~="navForward"]' | |
147 })) | |
148 | 85 |
149 | 86 |
150 class CalendarForwardBackwardPageSet(page_set_module.PageSet): | 87 class CalendarForwardBackwardPageSet(page_set_module.PageSet): |
151 | 88 |
152 """ Chrome Endure test for Google Calendar. """ | 89 """ Chrome Endure test for Google Calendar. """ |
153 | 90 |
154 def __init__(self): | 91 def __init__(self): |
155 super(CalendarForwardBackwardPageSet, self).__init__( | 92 super(CalendarForwardBackwardPageSet, self).__init__( |
156 credentials_path='data/credentials.json', | 93 credentials_path='data/credentials.json', |
157 user_agent_type='desktop', | 94 user_agent_type='desktop', |
158 archive_data_file='data/calendar_forward_backward.json') | 95 archive_data_file='data/calendar_forward_backward.json') |
159 | 96 |
160 self.AddPage(CalendarForwardBackwardPage(self)) | 97 self.AddPage(CalendarForwardBackwardPage(self)) |
OLD | NEW |