| 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 from telemetry.page import page as page_module | 4 from telemetry.page import page as page_module |
| 5 from telemetry.page import page_set as page_set_module | 5 from telemetry.page import page_set as page_set_module |
| 6 | 6 |
| 7 | 7 |
| 8 class SimpleScrollPage(page_module.Page): | 8 class SimplePage(page_module.Page): |
| 9 def __init__(self, url, page_set, credentials='', name=''): | 9 def __init__(self, url, page_set, credentials='', name=''): |
| 10 super(SimpleScrollPage, self).__init__( | 10 super(SimplePage, self).__init__( |
| 11 url, page_set=page_set, name=name, | 11 url, page_set=page_set, name=name, |
| 12 credentials_path='data/credentials.json') | 12 credentials_path='data/credentials.json') |
| 13 self.credentials = credentials | 13 self.credentials = credentials |
| 14 | 14 |
| 15 def RunPageInteractions(self, action_runner): | 15 def RunPageInteractions(self, action_runner): |
| 16 interaction = action_runner.BeginGestureInteraction( | 16 pass |
| 17 'ScrollAction', is_smooth=True) | |
| 18 action_runner.ScrollPage() | |
| 19 interaction.End() | |
| 20 | 17 |
| 21 class Google(SimpleScrollPage): | 18 class Google(SimplePage): |
| 22 def __init__(self, page_set): | 19 def __init__(self, page_set): |
| 23 super(Google, self).__init__( | 20 super(Google, self).__init__( |
| 24 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) |
| 25 | 22 |
| 26 def RunNavigateSteps(self, action_runner): | 23 def RunNavigateSteps(self, action_runner): |
| 27 super(Google, self).RunNavigateSteps(action_runner) | 24 super(Google, self).RunNavigateSteps(action_runner) |
| 28 action_runner.WaitForElement(text='Next') | 25 action_runner.WaitForElement(text='Next') |
| 29 | 26 |
| 30 | 27 |
| 31 class Gmail(SimpleScrollPage): | 28 class Gmail(SimplePage): |
| 32 def __init__(self, page_set): | 29 def __init__(self, page_set): |
| 33 super(Gmail, self).__init__( | 30 super(Gmail, self).__init__( |
| 34 url='https://mail.google.com/mail/', | 31 url='https://mail.google.com/mail/', |
| 35 page_set=page_set, | 32 page_set=page_set, |
| 36 credentials='google') | 33 credentials='google') |
| 37 | 34 |
| 38 def RunNavigateSteps(self, action_runner): | 35 def RunNavigateSteps(self, action_runner): |
| 39 super(Gmail, self).RunNavigateSteps(action_runner) | 36 super(Gmail, self).RunNavigateSteps(action_runner) |
| 40 action_runner.WaitForJavaScriptCondition( | 37 action_runner.WaitForJavaScriptCondition( |
| 41 'window.gmonkey !== undefined &&' | 38 'window.gmonkey !== undefined &&' |
| 42 'document.getElementById("gb") !== null') | 39 'document.getElementById("gb") !== null') |
| 43 | 40 |
| 44 | 41 |
| 45 class GoogleCalendar(SimpleScrollPage): | 42 class GoogleCalendar(SimplePage): |
| 46 def __init__(self, page_set): | 43 def __init__(self, page_set): |
| 47 super(GoogleCalendar, self).__init__( | 44 super(GoogleCalendar, self).__init__( |
| 48 url='https://www.google.com/calendar/', | 45 url='https://www.google.com/calendar/', |
| 49 page_set=page_set, | 46 page_set=page_set, |
| 50 credentials='google') | 47 credentials='google') |
| 51 | 48 |
| 52 def RunNavigateSteps(self, action_runner): | 49 def RunNavigateSteps(self, action_runner): |
| 53 super(GoogleCalendar, self).RunNavigateSteps(action_runner) | 50 super(GoogleCalendar, self).RunNavigateSteps(action_runner) |
| 54 action_runner.ExecuteJavaScript(''' | 51 action_runner.ExecuteJavaScript(''' |
| 55 (function() { var elem = document.createElement("meta"); | 52 (function() { var elem = document.createElement("meta"); |
| 56 elem.name="viewport"; | 53 elem.name="viewport"; |
| 57 elem.content="initial-scale=1"; | 54 elem.content="initial-scale=1"; |
| 58 document.body.appendChild(elem); | 55 document.body.appendChild(elem); |
| 59 })();''') | 56 })();''') |
| 60 action_runner.Wait(2) | 57 action_runner.Wait(2) |
| 61 action_runner.WaitForElement('div[class~="navForward"]') | 58 action_runner.WaitForElement('div[class~="navForward"]') |
| 62 | 59 |
| 63 | 60 |
| 64 class Youtube(SimpleScrollPage): | 61 class Youtube(SimplePage): |
| 65 def __init__(self, page_set): | 62 def __init__(self, page_set): |
| 66 super(Youtube, self).__init__( | 63 super(Youtube, self).__init__( |
| 67 url='http://www.youtube.com', | 64 url='http://www.youtube.com', |
| 68 page_set=page_set, | 65 page_set=page_set, |
| 69 credentials='google') | 66 credentials='google') |
| 70 | 67 |
| 71 def RunNavigateSteps(self, action_runner): | 68 def RunNavigateSteps(self, action_runner): |
| 72 super(Youtube, self).RunNavigateSteps(action_runner) | 69 super(Youtube, self).RunNavigateSteps(action_runner) |
| 73 action_runner.Wait(2) | 70 action_runner.Wait(2) |
| 74 | 71 |
| 75 | 72 |
| 76 class Facebook(SimpleScrollPage): | 73 class Facebook(SimplePage): |
| 77 def __init__(self, page_set): | 74 def __init__(self, page_set): |
| 78 super(Facebook, self).__init__( | 75 super(Facebook, self).__init__( |
| 79 url='http://www.facebook.com/barackobama', | 76 url='http://www.facebook.com/barackobama', |
| 80 page_set=page_set, | 77 page_set=page_set, |
| 81 credentials='facebook', | 78 credentials='facebook', |
| 82 name='Facebook') | 79 name='Facebook') |
| 83 | 80 |
| 84 def RunNavigateSteps(self, action_runner): | 81 def RunNavigateSteps(self, action_runner): |
| 85 super(Facebook, self).RunNavigateSteps(action_runner) | 82 super(Facebook, self).RunNavigateSteps(action_runner) |
| 86 action_runner.WaitForElement(text='About') | 83 action_runner.WaitForElement(text='About') |
| (...skipping 18 matching lines...) Expand all Loading... |
| 105 # productivity, top google properties | 102 # productivity, top google properties |
| 106 self.AddUserStory(GoogleCalendar(self)) | 103 self.AddUserStory(GoogleCalendar(self)) |
| 107 | 104 |
| 108 # #3 (Alexa global) | 105 # #3 (Alexa global) |
| 109 self.AddUserStory(Youtube(self)) | 106 self.AddUserStory(Youtube(self)) |
| 110 | 107 |
| 111 # top social, Public profile | 108 # top social, Public profile |
| 112 self.AddUserStory(Facebook(self)) | 109 self.AddUserStory(Facebook(self)) |
| 113 | 110 |
| 114 # #6 (Alexa) most visited worldwide,Picked an interesting page | 111 # #6 (Alexa) most visited worldwide,Picked an interesting page |
| 115 self.AddUserStory(SimpleScrollPage('http://en.wikipedia.org/wiki/Wikipedia', | 112 self.AddUserStory(SimplePage('http://en.wikipedia.org/wiki/Wikipedia', |
| 116 self, name='Wikipedia')) | 113 self, name='Wikipedia')) |
| 117 | 114 |
| 118 # #1 world commerce website by visits; #3 commerce in the US by time spent | 115 # #1 world commerce website by visits; #3 commerce in the US by time spent |
| 119 self.AddUserStory(SimpleScrollPage('http://www.amazon.com', self)) | 116 self.AddUserStory(SimplePage('http://www.amazon.com', self)) |
| 120 | 117 |
| 121 # #4 Alexa | 118 # #4 Alexa |
| 122 self.AddUserStory(SimpleScrollPage('http://www.yahoo.com/', self)) | 119 self.AddUserStory(SimplePage('http://www.yahoo.com/', self)) |
| 123 | 120 |
| 124 # #16 Alexa | 121 # #16 Alexa |
| 125 self.AddUserStory(SimpleScrollPage('http://www.bing.com/', self)) | 122 self.AddUserStory(SimplePage('http://www.bing.com/', self)) |
| 126 | 123 |
| 127 # #20 Alexa | 124 # #20 Alexa |
| 128 self.AddUserStory(SimpleScrollPage('http://www.ask.com/', self)) | 125 self.AddUserStory(SimplePage('http://www.ask.com/', self)) |
| OLD | NEW |