OLD | NEW |
1 #!/usr/bin/python2.4 | 1 #!/usr/bin/env python |
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Does scraping for all currently-known versions of Chrome""" | 6 """Does scraping for all currently-known versions of Chrome""" |
7 | 7 |
8 import pywintypes | 8 import pywintypes |
9 import types | 9 import types |
10 | 10 |
11 from drivers import keyboard | 11 from drivers import keyboard |
12 from drivers import mouse | 12 from drivers import mouse |
13 from drivers import windowing | 13 from drivers import windowing |
14 | 14 |
| 15 |
15 # TODO: this has moved, use some logic to find it. For now, | 16 # TODO: this has moved, use some logic to find it. For now, |
16 # expects a subst k:. | 17 # expects a subst k:. |
17 DEFAULT_PATH = r"k:\chrome.exe" | 18 DEFAULT_PATH = r"k:\chrome.exe" |
18 | 19 |
| 20 |
19 def InvokeBrowser(path): | 21 def InvokeBrowser(path): |
20 """Invoke the Chrome browser. | 22 """Invoke the Chrome browser. |
21 | 23 |
22 Args: | 24 Args: |
23 path: full path to browser | 25 path: full path to browser |
24 | 26 |
25 Returns: | 27 Returns: |
26 A tuple of (main window, process handle, address bar, render pane) | 28 A tuple of (main window, process handle, address bar, render pane) |
27 """ | 29 """ |
28 | 30 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 174 |
173 if proc: | 175 if proc: |
174 windowing.SetForegroundWindow(wnd) | 176 windowing.SetForegroundWindow(wnd) |
175 keyboard.TypeString(r"{\4}", use_modifiers=True) | 177 keyboard.TypeString(r"{\4}", use_modifiers=True) |
176 if not windowing.WaitForProcessExit(proc, timeout): | 178 if not windowing.WaitForProcessExit(proc, timeout): |
177 windowing.EndProcess(proc) | 179 windowing.EndProcess(proc) |
178 | 180 |
179 return ret | 181 return ret |
180 | 182 |
181 | 183 |
182 if __name__ == "__main__": | 184 def main(): |
183 # We're being invoked rather than imported, so run some tests | 185 # We're being invoked rather than imported, so run some tests |
184 path = r"c:\sitecompare\scrapes\chrome\0.1.97.0" | 186 path = r"c:\sitecompare\scrapes\chrome\0.1.97.0" |
185 windowing.PreparePath(path) | 187 windowing.PreparePath(path) |
186 | 188 |
187 # Scrape three sites and save the results | 189 # Scrape three sites and save the results |
188 Scrape([ | 190 Scrape([ |
189 "http://www.microsoft.com", | 191 "http://www.microsoft.com", |
190 "http://www.google.com", | 192 "http://www.google.com", |
191 "http://www.sun.com"], | 193 "http://www.sun.com"], |
192 path, (1024, 768), (0, 0)) | 194 path, (1024, 768), (0, 0)) |
| 195 return 0 |
193 | 196 |
| 197 |
| 198 if __name__ == "__main__": |
| 199 sys.exit(main()) |
OLD | NEW |