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

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

Issue 12224106: [chromedriver] Implement command: switchToWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 10 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 ctypes 8 import ctypes
9 import optparse 9 import optparse
10 import os 10 import os
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html')) 60 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html'))
61 window_count = len(self._driver.GetWindowHandles()) 61 window_count = len(self._driver.GetWindowHandles())
62 self._driver.FindElement('id', 'link').Click() 62 self._driver.FindElement('id', 'link').Click()
63 timeout = time.time() + 20 63 timeout = time.time() + 20
64 while time.time() < timeout: 64 while time.time() < timeout:
65 if (len(self._driver.GetWindowHandles()) > window_count): 65 if (len(self._driver.GetWindowHandles()) > window_count):
66 return 66 return
67 time.sleep(0.01) 67 time.sleep(0.01)
68 self.assertTrue(False) 68 self.assertTrue(False)
69 69
70 def testSwitchToWindow(self):
71 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html'))
72 self.assertEquals(
73 1, self._driver.ExecuteScript('window.name = "oldWindow"; return 1;'))
74 window1_handle = self._driver.GetCurrentWindowHandle()
75 window_count = len(self._driver.GetWindowHandles())
76 self._driver.FindElement('id', 'link').Click()
77 timeout = time.time() + 20
78 while time.time() < timeout:
79 all_handles = self._driver.GetWindowHandles()
80 if (len(all_handles) > window_count):
81 break
82 time.sleep(0.01)
83 self.assertTrue(window1_handle in all_handles)
84 all_handles.remove(window1_handle)
85 self._driver.SwitchToWindow(all_handles[0])
86 self.assertEquals(all_handles[0], self._driver.GetCurrentWindowHandle())
87 self.assertRaises(chromedriver.NoSuchElement,
88 self._driver.FindElement, 'id', 'link')
89 self._driver.SwitchToWindow('oldWindow')
90 self.assertEquals(window1_handle, self._driver.GetCurrentWindowHandle())
91
70 def testEvaluateScript(self): 92 def testEvaluateScript(self):
71 self.assertEquals(1, self._driver.ExecuteScript('return 1')) 93 self.assertEquals(1, self._driver.ExecuteScript('return 1'))
72 self.assertEquals(None, self._driver.ExecuteScript('')) 94 self.assertEquals(None, self._driver.ExecuteScript(''))
73 95
74 def testEvaluateScriptWithArgs(self): 96 def testEvaluateScriptWithArgs(self):
75 script = ('document.body.innerHTML = "<div>b</div><div>c</div>";' + 97 script = ('document.body.innerHTML = "<div>b</div><div>c</div>";' +
76 'return {stuff: document.querySelectorAll("div")};') 98 'return {stuff: document.querySelectorAll("div")};')
77 stuff = self._driver.ExecuteScript(script)['stuff'] 99 stuff = self._driver.ExecuteScript(script)['stuff']
78 script = 'return arguments[0].innerHTML + arguments[1].innerHTML' 100 script = 'return arguments[0].innerHTML + arguments[1].innerHTML'
79 self.assertEquals( 101 self.assertEquals(
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 global _ANDROID_PACKAGE 328 global _ANDROID_PACKAGE
307 _ANDROID_PACKAGE = options.android_package 329 _ANDROID_PACKAGE = options.android_package
308 330
309 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( 331 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule(
310 sys.modules[__name__]) 332 sys.modules[__name__])
311 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) 333 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter)
312 ChromeDriverTest.GlobalSetUp() 334 ChromeDriverTest.GlobalSetUp()
313 result = unittest.TextTestRunner().run(tests) 335 result = unittest.TextTestRunner().run(tests)
314 ChromeDriverTest.GlobalTearDown() 336 ChromeDriverTest.GlobalTearDown()
315 sys.exit(len(result.failures) + len(result.errors)) 337 sys.exit(len(result.failures) + len(result.errors))
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/command_executor_impl.cc ('k') | chrome/test/chromedriver/session_commands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698