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

Side by Side Diff: chrome/test/webdriver/chromedriver_tests.py

Issue 6630001: Allow webdriver users to choose between sending the key events when... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 9 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
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Tests for ChromeDriver. 7 """Tests for ChromeDriver.
8 8
9 If your test is testing a specific part of the WebDriver API, consider adding 9 If your test is testing a specific part of the WebDriver API, consider adding
10 it to the appropriate place in the WebDriver tree instead. 10 it to the appropriate place in the WebDriver tree instead.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 request_url = self._launcher.GetURL() + '/session/unkown_session_id' 104 request_url = self._launcher.GetURL() + '/session/unkown_session_id'
105 try: 105 try:
106 SendRequest(request_url, method='DELETE') 106 SendRequest(request_url, method='DELETE')
107 self.fail('Should have raised a urllib.HTTPError for returned 404') 107 self.fail('Should have raised a urllib.HTTPError for returned 404')
108 except urllib2.HTTPError, expected: 108 except urllib2.HTTPError, expected:
109 self.assertEquals(404, expected.code) 109 self.assertEquals(404, expected.code)
110 110
111 def testCanStartChromeDriverOnSpecificPort(self): 111 def testCanStartChromeDriverOnSpecificPort(self):
112 launcher = ChromeDriverLauncher(port=9520) 112 launcher = ChromeDriverLauncher(port=9520)
113 self.assertEquals(9520, launcher.GetPort()) 113 self.assertEquals(9520, launcher.GetPort())
114 driver = WebDriver(launcher.GetURL(), 'chrome', 'any') 114 driver = WebDriver(launcher.GetURL(), {})
kkania 2011/03/10 00:28:58 I think this will probably break the tests. The py
timothe faudot 2011/03/10 05:34:32 Yes this is the syntax for the 2.0b3 bindings, the
115 driver.quit() 115 driver.quit()
116 launcher.Kill() 116 launcher.Kill()
117 117
118 118
119 class CookieTest(unittest.TestCase): 119 class CookieTest(unittest.TestCase):
120 """Cookie test for the json webdriver protocol""" 120 """Cookie test for the json webdriver protocol"""
121 121
122 SEARCH = "http://www.google.com/webhp?hl=en" 122 SEARCH = "http://www.google.com/webhp?hl=en"
123 123
124 def setUp(self): 124 def setUp(self):
125 self._launcher = ChromeDriverLauncher() 125 self._launcher = ChromeDriverLauncher()
126 self._driver = WebDriver(self._launcher.GetURL(), 'chrome', 'any') 126 self._driver = WebDriver(self._launcher.GetURL(), {})
127 127
128 def tearDown(self): 128 def tearDown(self):
129 self._driver.quit() 129 self._driver.quit()
130 self._launcher.Kill() 130 self._launcher.Kill()
131 131
132 def testAddCookie(self): 132 def testAddCookie(self):
133 self._driver.get(self.SEARCH) 133 self._driver.get(self.SEARCH)
134 cookie_dict = None 134 cookie_dict = None
135 cookie_dict = self._driver.get_cookie("chromedriver_cookie_test") 135 cookie_dict = self._driver.get_cookie("chromedriver_cookie_test")
136 cookie_dict = {} 136 cookie_dict = {}
(...skipping 30 matching lines...) Expand all
167 self.assertTrue(isinstance(data, dict)) 167 self.assertTrue(isinstance(data, dict))
168 self.assertEquals(0, data['status']) 168 self.assertEquals(0, data['status'])
169 169
170 url_parts = urlparse.urlparse(self.session_url)[2].split('/') 170 url_parts = urlparse.urlparse(self.session_url)[2].split('/')
171 self.assertEquals(3, len(url_parts)) 171 self.assertEquals(3, len(url_parts))
172 self.assertEquals('', url_parts[0]) 172 self.assertEquals('', url_parts[0])
173 self.assertEquals('session', url_parts[1]) 173 self.assertEquals('session', url_parts[1])
174 self.assertEquals(data['sessionId'], url_parts[2]) 174 self.assertEquals(data['sessionId'], url_parts[2])
175 175
176 def testShouldBeGivenCapabilitiesWhenStartingASession(self): 176 def testShouldBeGivenCapabilitiesWhenStartingASession(self):
177 driver = WebDriver(self._launcher.GetURL(), 'chrome', 'any') 177 driver = WebDriver(self._launcher.GetURL(), {})
178 capabilities = driver.capabilities 178 capabilities = driver.capabilities
179 179
180 self.assertEquals('chrome', capabilities['browserName']) 180 self.assertEquals('chrome', capabilities['browserName'])
181 self.assertTrue(capabilities['javascriptEnabled']) 181 self.assertTrue(capabilities['javascriptEnabled'])
182 182
183 # Value depends on what version the server is starting. 183 # Value depends on what version the server is starting.
184 self.assertTrue('version' in capabilities) 184 self.assertTrue('version' in capabilities)
185 self.assertTrue( 185 self.assertTrue(
186 isinstance(capabilities['version'], unicode), 186 isinstance(capabilities['version'], unicode),
187 'Expected a %s, but was %s' % (unicode, 187 'Expected a %s, but was %s' % (unicode,
188 type(capabilities['version']))) 188 type(capabilities['version'])))
189 189
190 system = platform.system() 190 system = platform.system()
191 if system == 'Linux': 191 if system == 'Linux':
192 self.assertEquals('linux', capabilities['platform'].lower()) 192 self.assertEquals('linux', capabilities['platform'].lower())
193 elif system == 'Windows': 193 elif system == 'Windows':
194 self.assertEquals('windows', capabilities['platform'].lower()) 194 self.assertEquals('windows', capabilities['platform'].lower())
195 elif system == 'Darwin': 195 elif system == 'Darwin':
196 self.assertEquals('mac', capabilities['platform'].lower()) 196 self.assertEquals('mac', capabilities['platform'].lower())
197 else: 197 else:
198 # No python on ChromeOS, so we won't have a platform value, but 198 # No python on ChromeOS, so we won't have a platform value, but
199 # the server will know and return the value accordingly. 199 # the server will know and return the value accordingly.
200 self.assertEquals('chromeos', capabilities['platform'].lower()) 200 self.assertEquals('chromeos', capabilities['platform'].lower())
201 driver.quit() 201 driver.quit()
202 202
203 def testSessionCreationDeletion(self): 203 def testSessionCreationDeletion(self):
204 driver = WebDriver(self._launcher.GetURL(), 'chrome', 'any') 204 driver = WebDriver(self._launcher.GetURL(), {})
205 driver.quit() 205 driver.quit()
206 206
207 def testMultipleSessionCreationDeletion(self): 207 def testMultipleSessionCreationDeletion(self):
208 for i in range(10): 208 for i in range(10):
209 driver = WebDriver(self._launcher.GetURL(), 'chrome', 'any') 209 driver = WebDriver(self._launcher.GetURL(), {})
210 driver.quit() 210 driver.quit()
211 211
212 def testSessionCommandsAfterSessionDeletionReturn404(self): 212 def testSessionCommandsAfterSessionDeletionReturn404(self):
213 driver = WebDriver(self._launcher.GetURL(), 'chrome', 'any') 213 driver = WebDriver(self._launcher.GetURL(), {})
214 session_id = driver.session_id 214 session_id = driver.session_id
215 driver.quit() 215 driver.quit()
216 try: 216 try:
217 response = SendRequest(self._launcher.GetURL() + '/session/' + session_id, 217 response = SendRequest(self._launcher.GetURL() + '/session/' + session_id,
218 method='GET') 218 method='GET')
219 self.fail('Should have thrown 404 exception') 219 self.fail('Should have thrown 404 exception')
220 except urllib2.HTTPError, expected: 220 except urllib2.HTTPError, expected:
221 self.assertEquals(404, expected.code) 221 self.assertEquals(404, expected.code)
222 222
223 def testMultipleConcurrentSessions(self): 223 def testMultipleConcurrentSessions(self):
224 drivers = [] 224 drivers = []
225 for i in range(10): 225 for i in range(10):
226 drivers += [WebDriver(self._launcher.GetURL(), 'chrome', 'any')] 226 drivers += [WebDriver(self._launcher.GetURL(), {})]
227 for driver in drivers: 227 for driver in drivers:
228 driver.quit() 228 driver.quit()
229 229
230 230
231 class MouseTest(unittest.TestCase): 231 class MouseTest(unittest.TestCase):
232 """Mouse command tests for the json webdriver protocol""" 232 """Mouse command tests for the json webdriver protocol"""
233 233
234 def setUp(self): 234 def setUp(self):
235 self._launcher = ChromeDriverLauncher(root_path=os.path.dirname(__file__)) 235 self._launcher = ChromeDriverLauncher(root_path=os.path.dirname(__file__))
236 self._driver = WebDriver(self._launcher.GetURL(), 'chrome', 'any') 236 self._driver = WebDriver(self._launcher.GetURL(), {})
237 237
238 def tearDown(self): 238 def tearDown(self):
239 self._driver.quit() 239 self._driver.quit()
240 self._launcher.Kill() 240 self._launcher.Kill()
241 241
242 def testClickElementThatNeedsScrolling(self): 242 def testClickElementThatNeedsScrolling(self):
243 self._driver.get(self._launcher.GetURL() + '/test_page.html') 243 self._driver.get(self._launcher.GetURL() + '/test_page.html')
244 self._driver.find_element_by_name('hidden_scroll').click() 244 self._driver.find_element_by_name('hidden_scroll').click()
245 self.assertTrue(self._driver.execute_script('return window.success')) 245 self.assertTrue(self._driver.execute_script('return window.success'))
246 246
(...skipping 28 matching lines...) Expand all
275 self.assertEquals('', url_parts[0]) 275 self.assertEquals('', url_parts[0])
276 self.assertEquals('wd', url_parts[1]) 276 self.assertEquals('wd', url_parts[1])
277 self.assertEquals('hub', url_parts[2]) 277 self.assertEquals('hub', url_parts[2])
278 self.assertEquals('session', url_parts[3]) 278 self.assertEquals('session', url_parts[3])
279 self.assertEquals(data['sessionId'], url_parts[4]) 279 self.assertEquals(data['sessionId'], url_parts[4])
280 280
281 281
282 if __name__ == '__main__': 282 if __name__ == '__main__':
283 unittest.main(module='chromedriver_tests', 283 unittest.main(module='chromedriver_tests',
284 testRunner=GTestTextTestRunner(verbosity=1)) 284 testRunner=GTestTextTestRunner(verbosity=1))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698