Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 base64 | 8 import base64 |
| 9 import ctypes | 9 import ctypes |
| 10 import optparse | 10 import optparse |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 'document.body.innerHTML = "<div>old</div>";' | 240 'document.body.innerHTML = "<div>old</div>";' |
| 241 'var div = document.getElementsByTagName("div")[0];' | 241 'var div = document.getElementsByTagName("div")[0];' |
| 242 'div.addEventListener("click", function() {' | 242 'div.addEventListener("click", function() {' |
| 243 ' var div = document.getElementsByTagName("div")[0];' | 243 ' var div = document.getElementsByTagName("div")[0];' |
| 244 ' div.innerHTML="new<br>";' | 244 ' div.innerHTML="new<br>";' |
| 245 '});' | 245 '});' |
| 246 'return div;') | 246 'return div;') |
| 247 div.Click() | 247 div.Click() |
| 248 self.assertEquals(1, len(self._driver.FindElements('tag name', 'br'))) | 248 self.assertEquals(1, len(self._driver.FindElements('tag name', 'br'))) |
| 249 | 249 |
| 250 def testClickElementInSubFrame(self): | |
| 251 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/frame_test.html')) | |
| 252 frame = self._driver.FindElement('tag name', 'iframe') | |
| 253 self._driver.ExecuteScript('arguments[0].src = "empty.html";', frame) | |
|
chrisgao (Use stgao instead)
2013/03/12 17:41:18
A workaround for the hanging issue during switchin
| |
| 254 self._driver.SwitchToFrame(frame) | |
| 255 # Test clicking element in the sub frame. | |
| 256 self.testClickElement() | |
| 257 | |
| 250 def testClearElement(self): | 258 def testClearElement(self): |
| 251 text = self._driver.ExecuteScript( | 259 text = self._driver.ExecuteScript( |
| 252 'document.body.innerHTML = \'<input type="text" value="abc">\';' | 260 'document.body.innerHTML = \'<input type="text" value="abc">\';' |
| 253 'var input = document.getElementsByTagName("input")[0];' | 261 'var input = document.getElementsByTagName("input")[0];' |
| 254 'input.addEventListener("change", function() {' | 262 'input.addEventListener("change", function() {' |
| 255 ' document.body.appendChild(document.createElement("br"));' | 263 ' document.body.appendChild(document.createElement("br"));' |
| 256 '});' | 264 '});' |
| 257 'return input;') | 265 'return input;') |
| 258 text.Clear() | 266 text.Clear() |
| 259 self.assertEquals(1, len(self._driver.FindElements('tag name', 'br'))) | 267 self.assertEquals(1, len(self._driver.FindElements('tag name', 'br'))) |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 global _ANDROID_PACKAGE | 437 global _ANDROID_PACKAGE |
| 430 _ANDROID_PACKAGE = options.android_package | 438 _ANDROID_PACKAGE = options.android_package |
| 431 | 439 |
| 432 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( | 440 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( |
| 433 sys.modules[__name__]) | 441 sys.modules[__name__]) |
| 434 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) | 442 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) |
| 435 ChromeDriverTest.GlobalSetUp() | 443 ChromeDriverTest.GlobalSetUp() |
| 436 result = unittest.TextTestRunner(stream=sys.stdout).run(tests) | 444 result = unittest.TextTestRunner(stream=sys.stdout).run(tests) |
| 437 ChromeDriverTest.GlobalTearDown() | 445 ChromeDriverTest.GlobalTearDown() |
| 438 sys.exit(len(result.failures) + len(result.errors)) | 446 sys.exit(len(result.failures) + len(result.errors)) |
| OLD | NEW |