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

Side by Side Diff: chrome/test/chromedriver/test/run_py_tests.py

Issue 1882603003: [Chromedriver] Add testcase for testing alert on new window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """End to end tests for ChromeDriver.""" 6 """End to end tests for ChromeDriver."""
7 7
8 import base64 8 import base64
9 import json 9 import json
10 import math 10 import math
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 # This test is flaky since it uses setTimeout. 52 # This test is flaky since it uses setTimeout.
53 # Re-enable once crbug.com/177511 is fixed and we can remove setTimeout. 53 # Re-enable once crbug.com/177511 is fixed and we can remove setTimeout.
54 'ChromeDriverTest.testAlert', 54 'ChromeDriverTest.testAlert',
55 # This test is too flaky on the bots, but seems to run perfectly fine 55 # This test is too flaky on the bots, but seems to run perfectly fine
56 # on developer workstations. 56 # on developer workstations.
57 'ChromeDriverTest.testEmulateNetworkConditionsNameSpeed', 57 'ChromeDriverTest.testEmulateNetworkConditionsNameSpeed',
58 'ChromeDriverTest.testEmulateNetworkConditionsSpeed', 58 'ChromeDriverTest.testEmulateNetworkConditionsSpeed',
59 # crbug.com/469947 59 # crbug.com/469947
60 'ChromeDriverTest.testTouchPinch', 60 'ChromeDriverTest.testTouchPinch',
61 'ChromeDriverTest.testReturningAFunctionInJavascript', 61 'ChromeDriverTest.testReturningAFunctionInJavascript',
62 # https://bugs.chromium.org/p/chromedriver/issues/detail?id=833
63 'ChromeDriverTest.testAlertOnNewWindow',
62 ] 64 ]
63 65
64 _VERSION_SPECIFIC_FILTER = {} 66 _VERSION_SPECIFIC_FILTER = {}
65 _VERSION_SPECIFIC_FILTER['HEAD'] = [ 67 _VERSION_SPECIFIC_FILTER['HEAD'] = [
66 # https://code.google.com/p/chromedriver/issues/detail?id=992 68 # https://code.google.com/p/chromedriver/issues/detail?id=992
67 'ChromeDownloadDirTest.testDownloadDirectoryOverridesExistingPreferences', 69 'ChromeDownloadDirTest.testDownloadDirectoryOverridesExistingPreferences',
68 ] 70 ]
69 71
70 _OS_SPECIFIC_FILTER = {} 72 _OS_SPECIFIC_FILTER = {}
71 _OS_SPECIFIC_FILTER['win'] = [ 73 _OS_SPECIFIC_FILTER['win'] = [
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 'window.setTimeout(' 709 'window.setTimeout('
708 ' function() { window.confirmed = confirm(\'HI\'); },' 710 ' function() { window.confirmed = confirm(\'HI\'); },'
709 ' 0);') 711 ' 0);')
710 self.assertTrue(self._driver.IsAlertOpen()) 712 self.assertTrue(self._driver.IsAlertOpen())
711 self.assertEquals('HI', self._driver.GetAlertMessage()) 713 self.assertEquals('HI', self._driver.GetAlertMessage())
712 self._driver.HandleAlert(False) 714 self._driver.HandleAlert(False)
713 self.assertFalse(self._driver.IsAlertOpen()) 715 self.assertFalse(self._driver.IsAlertOpen())
714 self.assertEquals(False, 716 self.assertEquals(False,
715 self._driver.ExecuteScript('return window.confirmed')) 717 self._driver.ExecuteScript('return window.confirmed'))
716 718
719 def testAlertOnNewWindow(self):
720 self._http_server.SetDataForPath(
721 '/newwindowWithAlert',
722 """
723 <html>
724 <body>
725 <a href='%s' target='_blank'>new window having alert onload</a>
726 </body>
727 </html>""" % self.GetHttpUrlForFile('/chromedriver/alert_onload.html'))
728 self._driver.Load(self._http_server.GetUrl() + '/newwindowWithAlert')
samuong 2017/03/27 18:22:06 i'd suggest just loading about:blank, and then set
gmanikpure 2017/03/27 20:38:38 I get 'element not visible error' at line730 when
729 old_windows = self._driver.GetWindowHandles()
730 self._driver.FindElement('tagName', 'a').Click()
731 new_window = self.WaitForNewWindow(self._driver, old_windows)
732 self.assertNotEqual(None, new_window)
733 self._driver.SwitchToWindow(new_window)
734 self.assertTrue(self._driver.IsAlertOpen())
735 self._driver.HandleAlert(False)
736 self.assertFalse(self._driver.IsAlertOpen())
737
717 def testShouldHandleNewWindowLoadingProperly(self): 738 def testShouldHandleNewWindowLoadingProperly(self):
718 """Tests that ChromeDriver determines loading correctly for new windows.""" 739 """Tests that ChromeDriver determines loading correctly for new windows."""
719 self._http_server.SetDataForPath( 740 self._http_server.SetDataForPath(
720 '/newwindow', 741 '/newwindow',
721 """ 742 """
722 <html> 743 <html>
723 <body> 744 <body>
724 <a href='%s' target='_blank'>new window/tab</a> 745 <a href='%s' target='_blank'>new window/tab</a>
725 </body> 746 </body>
726 </html>""" % self._sync_server.GetUrl()) 747 </html>""" % self._sync_server.GetUrl())
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 1876
1856 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( 1877 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule(
1857 sys.modules[__name__]) 1878 sys.modules[__name__])
1858 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) 1879 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter)
1859 ChromeDriverTest.GlobalSetUp() 1880 ChromeDriverTest.GlobalSetUp()
1860 MobileEmulationCapabilityTest.GlobalSetUp() 1881 MobileEmulationCapabilityTest.GlobalSetUp()
1861 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) 1882 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests)
1862 ChromeDriverTest.GlobalTearDown() 1883 ChromeDriverTest.GlobalTearDown()
1863 MobileEmulationCapabilityTest.GlobalTearDown() 1884 MobileEmulationCapabilityTest.GlobalTearDown()
1864 sys.exit(len(result.failures) + len(result.errors)) 1885 sys.exit(len(result.failures) + len(result.errors))
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/chromedriver/alert_onload.html » ('j') | chrome/test/data/chromedriver/alert_onload.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698