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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 | 283 |
284 def tearDown(self): | 284 def tearDown(self): |
285 self._driver.quit() | 285 self._driver.quit() |
286 self._launcher.Kill() | 286 self._launcher.Kill() |
287 | 287 |
288 def testAddCookie(self): | 288 def testAddCookie(self): |
289 self._driver.get(self._launcher.GetURL() + '/test_page.html') | 289 self._driver.get(self._launcher.GetURL() + '/test_page.html') |
290 cookie_dict = None | 290 cookie_dict = None |
291 cookie_dict = self._driver.get_cookie("chromedriver_cookie_test") | 291 cookie_dict = self._driver.get_cookie("chromedriver_cookie_test") |
292 cookie_dict = {} | 292 cookie_dict = {} |
293 cookie_dict["name"]= "chromedriver_cookie_test" | 293 cookie_dict["name"] = "chromedriver_cookie_test" |
294 cookie_dict["value"] = "this is a test" | 294 cookie_dict["value"] = "this is a test" |
295 self._driver.add_cookie(cookie_dict) | 295 self._driver.add_cookie(cookie_dict) |
296 cookie_dict = self._driver.get_cookie("chromedriver_cookie_test") | 296 cookie_dict = self._driver.get_cookie("chromedriver_cookie_test") |
297 self.assertNotEqual(cookie_dict, None) | 297 self.assertNotEqual(cookie_dict, None) |
298 self.assertEqual(cookie_dict["value"], "this is a test") | 298 self.assertEqual(cookie_dict["value"], "this is a test") |
299 | 299 |
300 def testDeleteCookie(self): | 300 def testDeleteCookie(self): |
301 self.testAddCookie(); | 301 self.testAddCookie(); |
302 self._driver.delete_cookie("chromedriver_cookie_test") | 302 self._driver.delete_cookie("chromedriver_cookie_test") |
303 cookie_dict = self._driver.get_cookie("chromedriver_cookie_test") | 303 cookie_dict = self._driver.get_cookie("chromedriver_cookie_test") |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
589 'autofill-edit-credit-card-apply-button').click() | 589 'autofill-edit-credit-card-apply-button').click() |
590 # Refresh the page to ensure the UI is up-to-date. | 590 # Refresh the page to ensure the UI is up-to-date. |
591 driver.refresh() | 591 driver.refresh() |
592 list_entry = driver.find_element_by_class_name('autofill-list-item') | 592 list_entry = driver.find_element_by_class_name('autofill-list-item') |
593 self.assertTrue(list_entry.is_displayed) | 593 self.assertTrue(list_entry.is_displayed) |
594 self.assertEqual(list_entry.text, | 594 self.assertEqual(list_entry.text, |
595 creditcard_data['CREDIT_CARD_NAME'], | 595 creditcard_data['CREDIT_CARD_NAME'], |
596 'Saved CC line item not same as what was entered.') | 596 'Saved CC line item not same as what was entered.') |
597 | 597 |
598 | 598 |
599 class FileUploadControlTest(unittest.TestCase): | |
600 """Tests dealing with file upload control.""" | |
601 | |
602 def setUp(self): | |
603 self._launcher = ChromeDriverLauncher(root_path=os.path.dirname(__file__)) | |
604 self._driver = WebDriver(self._launcher.GetURL(), | |
605 DesiredCapabilities.CHROME) | |
606 | |
607 def tearDown(self): | |
608 self._driver.quit() | |
609 self._launcher.Kill() | |
610 | |
611 def testSetFilePathToFileUploadControl(self): | |
612 """Verify a file path is set to the file upload control.""" | |
613 self._driver.get(self._launcher.GetURL() + '/upload.html') | |
614 | |
615 f = self._driver.find_element_by_name('fileupload') | |
616 f.send_keys('upload.html') | |
617 path = f.value | |
618 self.assertTrue(path.endswith('upload.html')) | |
kkania
2011/06/01 16:16:41
can you also have a test for multiple files? Or is
nodchip
2011/06/02 07:15:53
Done.
| |
619 | |
620 | |
599 if __name__ == '__main__': | 621 if __name__ == '__main__': |
600 unittest.main(module='chromedriver_tests', | 622 unittest.main(module='chromedriver_tests', |
601 testRunner=GTestTextTestRunner(verbosity=1)) | 623 testRunner=GTestTextTestRunner(verbosity=1)) |
OLD | NEW |