| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import command_executor | 5 import command_executor |
| 6 from command_executor import Command | 6 from command_executor import Command |
| 7 from webelement import WebElement | 7 from webelement import WebElement |
| 8 | 8 |
| 9 | 9 |
| 10 class ChromeDriverException(Exception): | 10 class ChromeDriverException(Exception): |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 | 59 |
| 60 class ChromeDriver(object): | 60 class ChromeDriver(object): |
| 61 """Starts and controls a single Chrome instance on this machine.""" | 61 """Starts and controls a single Chrome instance on this machine.""" |
| 62 | 62 |
| 63 def __init__(self, server_url, chrome_binary=None, android_package=None, | 63 def __init__(self, server_url, chrome_binary=None, android_package=None, |
| 64 android_activity=None, android_process=None, | 64 android_activity=None, android_process=None, |
| 65 android_use_running_app=None, chrome_switches=None, | 65 android_use_running_app=None, chrome_switches=None, |
| 66 chrome_extensions=None, chrome_log_path=None, | 66 chrome_extensions=None, chrome_log_path=None, |
| 67 debugger_address=None, browser_log_level=None, | 67 debugger_address=None, browser_log_level=None, |
| 68 mobile_emulation=None, experimental_options=None): | 68 performance_log_level=None, mobile_emulation=None, |
| 69 experimental_options=None): |
| 69 self._executor = command_executor.CommandExecutor(server_url) | 70 self._executor = command_executor.CommandExecutor(server_url) |
| 70 | 71 |
| 71 options = {} | 72 options = {} |
| 72 | 73 |
| 73 if experimental_options: | 74 if experimental_options: |
| 74 assert isinstance(experimental_options, dict) | 75 assert isinstance(experimental_options, dict) |
| 75 options = experimental_options.copy() | 76 options = experimental_options.copy() |
| 76 | 77 |
| 77 if android_package: | 78 if android_package: |
| 78 options['androidPackage'] = android_package | 79 options['androidPackage'] = android_package |
| (...skipping 24 matching lines...) Expand all Loading... |
| 103 | 104 |
| 104 if debugger_address: | 105 if debugger_address: |
| 105 assert type(debugger_address) is str | 106 assert type(debugger_address) is str |
| 106 options['debuggerAddress'] = debugger_address | 107 options['debuggerAddress'] = debugger_address |
| 107 | 108 |
| 108 logging_prefs = {} | 109 logging_prefs = {} |
| 109 log_levels = ['ALL', 'DEBUG', 'INFO', 'WARNING', 'SEVERE', 'OFF'] | 110 log_levels = ['ALL', 'DEBUG', 'INFO', 'WARNING', 'SEVERE', 'OFF'] |
| 110 if browser_log_level: | 111 if browser_log_level: |
| 111 assert browser_log_level in log_levels | 112 assert browser_log_level in log_levels |
| 112 logging_prefs['browser'] = browser_log_level | 113 logging_prefs['browser'] = browser_log_level |
| 114 if performance_log_level: |
| 115 assert performance_log_level in log_levels |
| 116 logging_prefs['performance'] = performance_log_level |
| 113 | 117 |
| 114 params = { | 118 params = { |
| 115 'desiredCapabilities': { | 119 'desiredCapabilities': { |
| 116 'chromeOptions': options, | 120 'chromeOptions': options, |
| 117 'loggingPrefs': logging_prefs | 121 'loggingPrefs': logging_prefs |
| 118 } | 122 } |
| 119 } | 123 } |
| 120 | 124 |
| 121 response = self._ExecuteCommand(Command.NEW_SESSION, params) | 125 response = self._ExecuteCommand(Command.NEW_SESSION, params) |
| 122 self._session_id = response['sessionId'] | 126 self._session_id = response['sessionId'] |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 return self.ExecuteCommand(Command.GET_LOG, {'type': type}) | 339 return self.ExecuteCommand(Command.GET_LOG, {'type': type}) |
| 336 | 340 |
| 337 def GetAvailableLogTypes(self): | 341 def GetAvailableLogTypes(self): |
| 338 return self.ExecuteCommand(Command.GET_AVAILABLE_LOG_TYPES) | 342 return self.ExecuteCommand(Command.GET_AVAILABLE_LOG_TYPES) |
| 339 | 343 |
| 340 def IsAutoReporting(self): | 344 def IsAutoReporting(self): |
| 341 return self.ExecuteCommand(Command.IS_AUTO_REPORTING) | 345 return self.ExecuteCommand(Command.IS_AUTO_REPORTING) |
| 342 | 346 |
| 343 def SetAutoReporting(self, enabled): | 347 def SetAutoReporting(self, enabled): |
| 344 self.ExecuteCommand(Command.SET_AUTO_REPORTING, {'enabled': enabled}) | 348 self.ExecuteCommand(Command.SET_AUTO_REPORTING, {'enabled': enabled}) |
| OLD | NEW |