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

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

Issue 6723004: ChromeDriver should be able to focus on a frame using its frame element, (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.
11 """ 11 """
12 12
13 import platform 13 import platform
14 import os 14 import os
15 import sys 15 import sys
16 import unittest 16 import unittest
17 import urllib2 17 import urllib2
18 import urlparse 18 import urlparse
19 19
20 from chromedriver_launcher import ChromeDriverLauncher 20 from chromedriver_launcher import ChromeDriverLauncher
21 import chromedriver_paths 21 import chromedriver_paths
22 from gtest_text_test_runner import GTestTextTestRunner 22 from gtest_text_test_runner import GTestTextTestRunner
23 23
24 sys.path += [chromedriver_paths.SRC_THIRD_PARTY] 24 sys.path += [chromedriver_paths.SRC_THIRD_PARTY]
25 sys.path += [chromedriver_paths.PYTHON_BINDINGS] 25 sys.path += [chromedriver_paths.PYTHON_BINDINGS]
26 26
27 import simplejson as json 27 import simplejson as json
28 28
29 from selenium.webdriver.remote.command import Command
29 from selenium.webdriver.remote.webdriver import WebDriver 30 from selenium.webdriver.remote.webdriver import WebDriver
30 31
31 32
32 class Request(urllib2.Request): 33 class Request(urllib2.Request):
33 """Extends urllib2.Request to support all HTTP request types.""" 34 """Extends urllib2.Request to support all HTTP request types."""
34 35
35 def __init__(self, url, method=None, data=None): 36 def __init__(self, url, method=None, data=None):
36 """Initialise a new HTTP request. 37 """Initialise a new HTTP request.
37 38
38 Arguments: 39 Arguments:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 self.assertEquals('POST', expected.hdrs['Allow']) 102 self.assertEquals('POST', expected.hdrs['Allow'])
102 103
103 def testShouldGetA404WhenAttemptingToDeleteAnUnknownSession(self): 104 def testShouldGetA404WhenAttemptingToDeleteAnUnknownSession(self):
104 request_url = self._launcher.GetURL() + '/session/unkown_session_id' 105 request_url = self._launcher.GetURL() + '/session/unkown_session_id'
105 try: 106 try:
106 SendRequest(request_url, method='DELETE') 107 SendRequest(request_url, method='DELETE')
107 self.fail('Should have raised a urllib.HTTPError for returned 404') 108 self.fail('Should have raised a urllib.HTTPError for returned 404')
108 except urllib2.HTTPError, expected: 109 except urllib2.HTTPError, expected:
109 self.assertEquals(404, expected.code) 110 self.assertEquals(404, expected.code)
110 111
112 def testShouldReturn204ForFaviconRequests(self):
113 request_url = self._launcher.GetURL() + '/favicon.ico'
114 response = SendRequest(request_url, method='GET')
115 try:
116 self.assertEquals(204, response.code)
117 finally:
118 response.close()
119
111 def testCanStartChromeDriverOnSpecificPort(self): 120 def testCanStartChromeDriverOnSpecificPort(self):
112 launcher = ChromeDriverLauncher(port=9520) 121 launcher = ChromeDriverLauncher(port=9520)
113 self.assertEquals(9520, launcher.GetPort()) 122 self.assertEquals(9520, launcher.GetPort())
114 driver = WebDriver(launcher.GetURL(), {}) 123 driver = WebDriver(launcher.GetURL(), {})
115 driver.quit() 124 driver.quit()
116 launcher.Kill() 125 launcher.Kill()
117 126
118 127
119 class CookieTest(unittest.TestCase): 128 class CookieTest(unittest.TestCase):
120 """Cookie test for the json webdriver protocol""" 129 """Cookie test for the json webdriver protocol"""
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 self.assertTrue(isinstance(data, dict)) 290 self.assertTrue(isinstance(data, dict))
282 self.assertEquals(0, data['status']) 291 self.assertEquals(0, data['status'])
283 292
284 url_parts = urlparse.urlparse(self.session_url)[2].split('/') 293 url_parts = urlparse.urlparse(self.session_url)[2].split('/')
285 self.assertEquals(5, len(url_parts)) 294 self.assertEquals(5, len(url_parts))
286 self.assertEquals('', url_parts[0]) 295 self.assertEquals('', url_parts[0])
287 self.assertEquals('wd', url_parts[1]) 296 self.assertEquals('wd', url_parts[1])
288 self.assertEquals('hub', url_parts[2]) 297 self.assertEquals('hub', url_parts[2])
289 self.assertEquals('session', url_parts[3]) 298 self.assertEquals('session', url_parts[3])
290 self.assertEquals(data['sessionId'], url_parts[4]) 299 self.assertEquals(data['sessionId'], url_parts[4])
291 300
kkania 2011/03/24 17:19:33 how about a test for switching to a frame by eleme
Jason Leyba 2011/03/24 17:27:53 There are some in the WebDriver python tests, whic
292 301
302 # TODO(jleyba): Port this to WebDriver's own python test suite.
303 class ElementEqualityTest(unittest.TestCase):
304 """Tests that the server properly checks element equality."""
305
306 def setUp(self):
307 self._launcher = ChromeDriverLauncher(root_path=os.path.dirname(__file__))
308 self._driver = WebDriver(self._launcher.GetURL(), {})
309
310 def tearDown(self):
311 self._driver.quit()
312 self._launcher.Kill()
313
314 def testElementEquality(self):
315 self._driver.get(self._launcher.GetURL() + '/test_page.html')
316 body1 = self._driver.find_element_by_tag_name('body')
317 body2 = self._driver.execute_script('return document.body')
318
319 # TODO(jleyba): WebDriver's python bindings should expose a proper API
320 # for this.
321 result = body1.execute(Command.ELEMENT_EQUALS, {
322 'other': body2.id
323 })
324 self.assertTrue(result['value'])
325
326
293 if __name__ == '__main__': 327 if __name__ == '__main__':
294 unittest.main(module='chromedriver_tests', 328 unittest.main(module='chromedriver_tests',
295 testRunner=GTestTextTestRunner(verbosity=1)) 329 testRunner=GTestTextTestRunner(verbosity=1))
OLDNEW
« no previous file with comments | « chrome/test/webdriver/WEBDRIVER_TESTS ('k') | chrome/test/webdriver/commands/find_element_commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698