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

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

Issue 2743013002: Add webdriver endpoint to send custom debugger commands (Closed)
Patch Set: Adding e2e test Created 3 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 # https://bugs.chromium.org/p/chromedriver/issues/detail?id=1503 172 # https://bugs.chromium.org/p/chromedriver/issues/detail?id=1503
173 'ChromeDriverTest.testShadowDomHover', 173 'ChromeDriverTest.testShadowDomHover',
174 'ChromeDriverTest.testMouseMoveTo', 174 'ChromeDriverTest.testMouseMoveTo',
175 'ChromeDriverTest.testHoverOverElement', 175 'ChromeDriverTest.testHoverOverElement',
176 # https://bugs.chromium.org/p/chromedriver/issues/detail?id=1478 176 # https://bugs.chromium.org/p/chromedriver/issues/detail?id=1478
177 'ChromeDriverTest.testShouldHandleNewWindowLoadingProperly', 177 'ChromeDriverTest.testShouldHandleNewWindowLoadingProperly',
178 ] 178 ]
179 ) 179 )
180 _ANDROID_NEGATIVE_FILTER['chromedriver_webview_shell'] = ( 180 _ANDROID_NEGATIVE_FILTER['chromedriver_webview_shell'] = (
181 _ANDROID_NEGATIVE_FILTER['chrome'] + [ 181 _ANDROID_NEGATIVE_FILTER['chrome'] + [
182 'PerformanceLoggerTest.testPerformanceLogger', 182 'ChromeLoggingCapabilityTest.testPerformanceLogger',
183 'ChromeDriverTest.testShadowDom*', 183 'ChromeDriverTest.testShadowDom*',
184 # WebView doesn't support emulating network conditions. 184 # WebView doesn't support emulating network conditions.
185 'ChromeDriverTest.testEmulateNetworkConditions', 185 'ChromeDriverTest.testEmulateNetworkConditions',
186 'ChromeDriverTest.testEmulateNetworkConditionsNameSpeed', 186 'ChromeDriverTest.testEmulateNetworkConditionsNameSpeed',
187 'ChromeDriverTest.testEmulateNetworkConditionsOffline', 187 'ChromeDriverTest.testEmulateNetworkConditionsOffline',
188 'ChromeDriverTest.testEmulateNetworkConditionsSpeed', 188 'ChromeDriverTest.testEmulateNetworkConditionsSpeed',
189 'ChromeDriverTest.testEmulateNetworkConditionsName', 189 'ChromeDriverTest.testEmulateNetworkConditionsName',
190 # The WebView shell that we test against (on KitKat) does not yet 190 # The WebView shell that we test against (on KitKat) does not yet
191 # support Synthetic Gesture DevTools commands. 191 # support Synthetic Gesture DevTools commands.
192 # TODO(samuong): reenable when it does. 192 # TODO(samuong): reenable when it does.
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 def testEmulateNetworkConditionsOffline(self): 1034 def testEmulateNetworkConditionsOffline(self):
1035 # A workaround for crbug.com/177511; when setting offline, the throughputs 1035 # A workaround for crbug.com/177511; when setting offline, the throughputs
1036 # must be 0. 1036 # must be 0.
1037 self._driver.SetNetworkConditions(0, 0, 0, offline=True) 1037 self._driver.SetNetworkConditions(0, 0, 0, offline=True)
1038 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html')) 1038 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html'))
1039 # The "X is not available" title is set after the page load event fires, so 1039 # The "X is not available" title is set after the page load event fires, so
1040 # we have to explicitly wait for this to change. We can't rely on the 1040 # we have to explicitly wait for this to change. We can't rely on the
1041 # navigation tracker to block the call to Load() above. 1041 # navigation tracker to block the call to Load() above.
1042 self.WaitForCondition(lambda: 'is not available' in self._driver.GetTitle()) 1042 self.WaitForCondition(lambda: 'is not available' in self._driver.GetTitle())
1043 1043
1044 def testSendCommand(self):
1045 #Sends a custom command to the DevTools debugger
1046 params = {}
1047 res = self._driver.SendCommandAndGetResult('CSS.enable', params)
1048 self.assertEqual({}, res)
1049
1050 def testSendCommandNoParams(self):
1051 #Sends a custom command to the DevTools debugger
1052 self.assertRaisesRegexp(
1053 chromedriver.UnknownError, "params not passed",
1054 self._driver.SendCommandAndGetResult, 'CSS.enable', None)
1055
1056 def testSendCommandAndGetResult(self):
1057 #Sends a custom command to the DevTools debugger and gets the result
1058 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html'))
1059 params = {}
1060 document = self._driver.SendCommandAndGetResult('DOM.getDocument', params)
1061 self.assertTrue('root' in document)
1062
1044 def testShadowDomFindElementWithSlashDeep(self): 1063 def testShadowDomFindElementWithSlashDeep(self):
1045 """Checks that chromedriver can find elements in a shadow DOM using /deep/ 1064 """Checks that chromedriver can find elements in a shadow DOM using /deep/
1046 css selectors.""" 1065 css selectors."""
1047 self._driver.Load(self.GetHttpUrlForFile( 1066 self._driver.Load(self.GetHttpUrlForFile(
1048 '/chromedriver/shadow_dom_test.html')) 1067 '/chromedriver/shadow_dom_test.html'))
1049 self.assertTrue(self._driver.FindElement("css", "* /deep/ #olderTextBox")) 1068 self.assertTrue(self._driver.FindElement("css", "* /deep/ #olderTextBox"))
1050 1069
1051 def testShadowDomFindChildElement(self): 1070 def testShadowDomFindChildElement(self):
1052 """Checks that chromedriver can find child elements from a shadow DOM 1071 """Checks that chromedriver can find child elements from a shadow DOM
1053 element.""" 1072 element."""
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 driver.Load( 2193 driver.Load(
2175 ChromeDriverTest._http_server.GetUrl() + '/chromedriver/empty.html') 2194 ChromeDriverTest._http_server.GetUrl() + '/chromedriver/empty.html')
2176 driver.AddCookie({'name': 'secret_code', 'value': 'bosco'}) 2195 driver.AddCookie({'name': 'secret_code', 'value': 'bosco'})
2177 driver.Quit() 2196 driver.Quit()
2178 finally: 2197 finally:
2179 chromedriver_server.Kill() 2198 chromedriver_server.Kill()
2180 with open(tmp_log_path, 'r') as f: 2199 with open(tmp_log_path, 'r') as f:
2181 self.assertNotIn('bosco', f.read()) 2200 self.assertNotIn('bosco', f.read())
2182 2201
2183 2202
2184 class PerformanceLoggerTest(ChromeDriverBaseTest): 2203 class ChromeLoggingCapabilityTest(ChromeDriverBaseTest):
2185 """Tests chromedriver tracing support and Inspector event collection.""" 2204 """Tests chromedriver tracing support and Inspector event collection."""
2186 2205
2187 def testPerformanceLogger(self): 2206 def testPerformanceLogger(self):
2188 driver = self.CreateDriver( 2207 driver = self.CreateDriver(
2189 experimental_options={'perfLoggingPrefs': { 2208 experimental_options={'perfLoggingPrefs': {
2190 'traceCategories': 'webkit.console,blink.console' 2209 'traceCategories': 'webkit.console,blink.console'
2191 }}, logging_prefs={'performance':'ALL'}) 2210 }}, logging_prefs={'performance':'ALL'})
2192 driver.Load( 2211 driver.Load(
2193 ChromeDriverTest._http_server.GetUrl() + '/chromedriver/empty.html') 2212 ChromeDriverTest._http_server.GetUrl() + '/chromedriver/empty.html')
2194 # Mark the timeline; later we will verify the marks appear in the trace. 2213 # Mark the timeline; later we will verify the marks appear in the trace.
(...skipping 16 matching lines...) Expand all
2211 cat = devtools_message['params'].get('cat', '') 2230 cat = devtools_message['params'].get('cat', '')
2212 # Depending on Chrome version, the events may occur for the webkit.console 2231 # Depending on Chrome version, the events may occur for the webkit.console
2213 # or blink.console category. They will only occur for one of them. 2232 # or blink.console category. They will only occur for one of them.
2214 if (cat == 'blink.console' or cat == 'webkit.console'): 2233 if (cat == 'blink.console' or cat == 'webkit.console'):
2215 self.assertTrue(devtools_message['params']['name'] == 'foobar') 2234 self.assertTrue(devtools_message['params']['name'] == 'foobar')
2216 marked_timeline_events.append(devtools_message) 2235 marked_timeline_events.append(devtools_message)
2217 self.assertEquals(2, len(marked_timeline_events)) 2236 self.assertEquals(2, len(marked_timeline_events))
2218 self.assertEquals({'Network', 'Page', 'Tracing'}, 2237 self.assertEquals({'Network', 'Page', 'Tracing'},
2219 set(seen_log_domains.keys())) 2238 set(seen_log_domains.keys()))
2220 2239
2240 def testDevToolsEventsLogger(self):
2241 event = 'Page.loadEventFired'
2242 driver = self.CreateDriver(
2243 devtools_events_to_log=[event], logging_prefs={'devtools':'ALL'})
2244 driver.Load('about:blank')
2245 logs = driver.GetLog('devtools')
2246 print logs
2247 for entry in logs:
2248 devtools_message = json.loads(entry['message'])
2249 method = devtools_message['method']
2250 self.assertTrue('params' in devtools_message)
2251 self.assertEquals(event, method)
2221 2252
2222 class SessionHandlingTest(ChromeDriverBaseTest): 2253 class SessionHandlingTest(ChromeDriverBaseTest):
2223 """Tests for session operations.""" 2254 """Tests for session operations."""
2224 def testQuitASessionMoreThanOnce(self): 2255 def testQuitASessionMoreThanOnce(self):
2225 driver = self.CreateDriver() 2256 driver = self.CreateDriver()
2226 driver.Quit() 2257 driver.Quit()
2227 driver.Quit() 2258 driver.Quit()
2228 2259
2229 def testGetSessions(self): 2260 def testGetSessions(self):
2230 driver = self.CreateDriver() 2261 driver = self.CreateDriver()
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2406 2437
2407 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( 2438 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule(
2408 sys.modules[__name__]) 2439 sys.modules[__name__])
2409 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) 2440 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter)
2410 ChromeDriverTest.GlobalSetUp() 2441 ChromeDriverTest.GlobalSetUp()
2411 MobileEmulationCapabilityTest.GlobalSetUp() 2442 MobileEmulationCapabilityTest.GlobalSetUp()
2412 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) 2443 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests)
2413 ChromeDriverTest.GlobalTearDown() 2444 ChromeDriverTest.GlobalTearDown()
2414 MobileEmulationCapabilityTest.GlobalTearDown() 2445 MobileEmulationCapabilityTest.GlobalTearDown()
2415 sys.exit(len(result.failures) + len(result.errors)) 2446 sys.exit(len(result.failures) + len(result.errors))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698