| OLD | NEW |
| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 self.assertNotEqual(cookie_dict, None) | 141 self.assertNotEqual(cookie_dict, None) |
| 142 self.assertEqual(cookie_dict["value"], "this is a test"); | 142 self.assertEqual(cookie_dict["value"], "this is a test"); |
| 143 | 143 |
| 144 def testDeleteCookie(self): | 144 def testDeleteCookie(self): |
| 145 self.testAddCookie(); | 145 self.testAddCookie(); |
| 146 self._driver.delete_cookie("chromedriver_cookie_test") | 146 self._driver.delete_cookie("chromedriver_cookie_test") |
| 147 cookie_dict = self._driver.get_cookie("chromedriver_cookie_test") | 147 cookie_dict = self._driver.get_cookie("chromedriver_cookie_test") |
| 148 self.assertEqual(cookie_dict, None) | 148 self.assertEqual(cookie_dict, None) |
| 149 | 149 |
| 150 | 150 |
| 151 class ScreenshotTest(unittest.TestCase): |
| 152 """Tests to verify screenshot retrieval""" |
| 153 |
| 154 SEARCH = "http://www.google.com/webhp?hl=en" |
| 155 NEWS = "http://www.google.com/news" |
| 156 |
| 157 def setUp(self): |
| 158 self._launcher = ChromeDriverLauncher() |
| 159 self._driver = WebDriver(self._launcher.GetURL(), {}) |
| 160 |
| 161 def tearDown(self): |
| 162 self._driver.quit() |
| 163 self._launcher.Kill() |
| 164 |
| 165 def testScreenCapture(self): |
| 166 self._driver.get(self.SEARCH) |
| 167 s1 = self._driver.get_screenshot_as_base64() |
| 168 self._driver.get(self.NEWS) |
| 169 s2 = self._driver.get_screenshot_as_base64() |
| 170 self.assertTrue(len(s1) > 0 and len(s2) > 0) |
| 171 self.assertTrue(len(s1) != len(s2)) |
| 172 |
| 173 |
| 151 class SessionTest(unittest.TestCase): | 174 class SessionTest(unittest.TestCase): |
| 152 """Tests dealing with WebDriver sessions.""" | 175 """Tests dealing with WebDriver sessions.""" |
| 153 | 176 |
| 154 def setUp(self): | 177 def setUp(self): |
| 155 self._launcher = ChromeDriverLauncher() | 178 self._launcher = ChromeDriverLauncher() |
| 156 | 179 |
| 157 def tearDown(self): | 180 def tearDown(self): |
| 158 self._launcher.Kill() | 181 self._launcher.Kill() |
| 159 | 182 |
| 160 def testCreatingSessionShouldRedirectToCorrectURL(self): | 183 def testCreatingSessionShouldRedirectToCorrectURL(self): |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 self.assertEquals('', url_parts[0]) | 311 self.assertEquals('', url_parts[0]) |
| 289 self.assertEquals('wd', url_parts[1]) | 312 self.assertEquals('wd', url_parts[1]) |
| 290 self.assertEquals('hub', url_parts[2]) | 313 self.assertEquals('hub', url_parts[2]) |
| 291 self.assertEquals('session', url_parts[3]) | 314 self.assertEquals('session', url_parts[3]) |
| 292 self.assertEquals(data['sessionId'], url_parts[4]) | 315 self.assertEquals(data['sessionId'], url_parts[4]) |
| 293 | 316 |
| 294 | 317 |
| 295 if __name__ == '__main__': | 318 if __name__ == '__main__': |
| 296 unittest.main(module='chromedriver_tests', | 319 unittest.main(module='chromedriver_tests', |
| 297 testRunner=GTestTextTestRunner(verbosity=1)) | 320 testRunner=GTestTextTestRunner(verbosity=1)) |
| OLD | NEW |