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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 body2 = self._driver.execute_script('return document.body') | 496 body2 = self._driver.execute_script('return document.body') |
497 | 497 |
498 # TODO(jleyba): WebDriver's python bindings should expose a proper API | 498 # TODO(jleyba): WebDriver's python bindings should expose a proper API |
499 # for this. | 499 # for this. |
500 result = body1._execute(Command.ELEMENT_EQUALS, { | 500 result = body1._execute(Command.ELEMENT_EQUALS, { |
501 'other': body2.id | 501 'other': body2.id |
502 }) | 502 }) |
503 self.assertTrue(result['value']) | 503 self.assertTrue(result['value']) |
504 | 504 |
505 | 505 |
| 506 class LoggingTest(unittest.TestCase): |
| 507 |
| 508 def setUp(self): |
| 509 self._launcher = ChromeDriverLauncher(root_path=os.path.dirname(__file__)) |
| 510 |
| 511 def tearDown(self): |
| 512 self._launcher.Kill() |
| 513 |
| 514 def testNoVerboseLogging(self): |
| 515 self._driver = WebDriver(self._launcher.GetURL(), {}) |
| 516 self._driver.execute_script('console.log("HI")') |
| 517 request_url = self._launcher.GetURL() + '/log' |
| 518 req = SendRequest(request_url, method='GET') |
| 519 log = req.read() |
| 520 self.assertTrue(':INFO:' not in log, ':INFO: in log: ' + log) |
| 521 |
| 522 def testVerboseLogging(self): |
| 523 self._driver = WebDriver(self._launcher.GetURL(), {'chrome.verbose': True}) |
| 524 self._driver.execute_script('console.log("HI")') |
| 525 request_url = self._launcher.GetURL() + '/log' |
| 526 req = SendRequest(request_url, method='GET') |
| 527 log = req.read() |
| 528 self.assertTrue(':INFO:' in log, ':INFO: not in log: ' + log) |
| 529 |
| 530 |
506 """Chrome functional test section. All implementation tests of ChromeDriver | 531 """Chrome functional test section. All implementation tests of ChromeDriver |
507 should go above. | 532 should go above. |
508 | 533 |
509 TODO(dyu): Move these tests out of here when pyauto has these capabilities. | 534 TODO(dyu): Move these tests out of here when pyauto has these capabilities. |
510 """ | 535 """ |
511 | 536 |
512 | 537 |
513 def GetPathForDataFile(relative_path): | 538 def GetPathForDataFile(relative_path): |
514 """Returns the path for a test data file residing in this directory.""" | 539 """Returns the path for a test data file residing in this directory.""" |
515 return os.path.join(os.path.dirname(__file__), relative_path) | 540 return os.path.join(os.path.dirname(__file__), relative_path) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 list_entry = driver.find_element_by_class_name('autofill-list-item') | 617 list_entry = driver.find_element_by_class_name('autofill-list-item') |
593 self.assertTrue(list_entry.is_displayed) | 618 self.assertTrue(list_entry.is_displayed) |
594 self.assertEqual(list_entry.text, | 619 self.assertEqual(list_entry.text, |
595 creditcard_data['CREDIT_CARD_NAME'], | 620 creditcard_data['CREDIT_CARD_NAME'], |
596 'Saved CC line item not same as what was entered.') | 621 'Saved CC line item not same as what was entered.') |
597 | 622 |
598 | 623 |
599 if __name__ == '__main__': | 624 if __name__ == '__main__': |
600 unittest.main(module='chromedriver_tests', | 625 unittest.main(module='chromedriver_tests', |
601 testRunner=GTestTextTestRunner(verbosity=1)) | 626 testRunner=GTestTextTestRunner(verbosity=1)) |
OLD | NEW |