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

Side by Side Diff: chrome_frame/tools/test/page_cycler/cf_cycler.py

Issue 218019: Initial import of the Chrome Frame codebase. Integration in chrome.gyp coming... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome_frame/test_utils.cc ('k') | chrome_frame/tools/test/page_cycler/urllist » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Automates IE to visit a list of web sites while running CF in full tab mode.
6
7 The page cycler automates IE and navigates it to a series of URLs. It is
8 designed to be run with Chrome Frame configured to load every URL inside
9 CF full tab mode.
10
11 TODO(robertshield): Make use of the python unittest module as per
12 review comments.
13 """
14
15 import optparse
16 import sys
17 import time
18 import win32com.client
19 import win32gui
20
21 def LoadSiteList(path):
22 """Loads a list of URLs from |path|.
23
24 Expects the URLs to be separated by newlines, with no leading or trailing
25 whitespace.
26
27 Args:
28 path: The path to a file containing a list of new-line separated URLs.
29
30 Returns:
31 A list of strings, each one a URL.
32 """
33 f = open(path)
34 urls = f.readlines()
35 f.close()
36 return urls
37
38 def LaunchIE():
39 """Starts up IE, makes it visible and returns the automation object.
40
41 Returns:
42 The IE automation object.
43 """
44 ie = win32com.client.Dispatch("InternetExplorer.Application")
45 ie.visible = 1
46 win32gui.SetForegroundWindow(ie.HWND)
47 return ie
48
49 def RunTest(url, ie):
50 """Loads |url| into the InternetExplorer.Application instance in |ie|.
51
52 Waits for the Document object to be created and then waits for
53 the document ready state to reach READYSTATE_COMPLETE.
54 Args:
55 url: A string containing the url to navigate to.
56 ie: The IE automation object to navigate.
57 """
58
59 print "Navigating to " + url
60 ie.Navigate(url)
61 timer = 0
62
63 READYSTATE_COMPLETE = 4
64
65 last_ready_state = -1
66 for retry in xrange(60):
67 try:
68 # TODO(robertshield): Become an event sink instead of polling for
69 # changes to the ready state.
70 last_ready_state = ie.Document.ReadyState
71 if last_ready_state == READYSTATE_COMPLETE:
72 break
73 except:
74 # TODO(robertshield): Find the precise exception related to ie.Document
75 # being not accessible and handle it here.
76 print "Unexpected error:", sys.exc_info()[0]
77 raise
78 time.sleep(1)
79
80 if last_ready_state != READYSTATE_COMPLETE:
81 print "Timeout waiting for " + url
82
83 def main():
84 parser = optparse.OptionParser()
85 parser.add_option('-u', '--url_list', default='urllist',
86 help='The path to the list of URLs')
87 (opts, args) = parser.parse_args()
88
89 urls = LoadSiteList(opts.url_list)
90 ie = LaunchIE()
91 for url in urls:
92 RunTest(url, ie)
93 time.sleep(1)
94 ie.visible = 0
95 ie.Quit()
96
97
98 if __name__ == '__main__':
99 main()
OLDNEW
« no previous file with comments | « chrome_frame/test_utils.cc ('k') | chrome_frame/tools/test/page_cycler/urllist » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698