| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 performance_log_level=None, mobile_emulation=None, | 68 performance_log_level=None, mobile_emulation=None, |
| 69 experimental_options=None): | 69 experimental_options=None, download_dir=None): |
| 70 self._executor = command_executor.CommandExecutor(server_url) | 70 self._executor = command_executor.CommandExecutor(server_url) |
| 71 | 71 |
| 72 options = {} | 72 options = {} |
| 73 | 73 |
| 74 if experimental_options: | 74 if experimental_options: |
| 75 assert isinstance(experimental_options, dict) | 75 assert isinstance(experimental_options, dict) |
| 76 options = experimental_options.copy() | 76 options = experimental_options.copy() |
| 77 | 77 |
| 78 if android_package: | 78 if android_package: |
| 79 options['androidPackage'] = android_package | 79 options['androidPackage'] = android_package |
| (...skipping 28 matching lines...) Expand all Loading... |
| 108 | 108 |
| 109 logging_prefs = {} | 109 logging_prefs = {} |
| 110 log_levels = ['ALL', 'DEBUG', 'INFO', 'WARNING', 'SEVERE', 'OFF'] | 110 log_levels = ['ALL', 'DEBUG', 'INFO', 'WARNING', 'SEVERE', 'OFF'] |
| 111 if browser_log_level: | 111 if browser_log_level: |
| 112 assert browser_log_level in log_levels | 112 assert browser_log_level in log_levels |
| 113 logging_prefs['browser'] = browser_log_level | 113 logging_prefs['browser'] = browser_log_level |
| 114 if performance_log_level: | 114 if performance_log_level: |
| 115 assert performance_log_level in log_levels | 115 assert performance_log_level in log_levels |
| 116 logging_prefs['performance'] = performance_log_level | 116 logging_prefs['performance'] = performance_log_level |
| 117 | 117 |
| 118 download_prefs = {} |
| 119 if download_dir: |
| 120 if 'prefs' not in options: |
| 121 options['prefs'] = {} |
| 122 if 'download' not in options['prefs']: |
| 123 options['prefs']['download'] = {} |
| 124 options['prefs']['download']['default_directory'] = download_dir |
| 125 |
| 118 params = { | 126 params = { |
| 119 'desiredCapabilities': { | 127 'desiredCapabilities': { |
| 120 'chromeOptions': options, | 128 'chromeOptions': options, |
| 121 'loggingPrefs': logging_prefs | 129 'loggingPrefs': logging_prefs |
| 122 } | 130 } |
| 123 } | 131 } |
| 124 | 132 |
| 125 response = self._ExecuteCommand(Command.NEW_SESSION, params) | 133 response = self._ExecuteCommand(Command.NEW_SESSION, params) |
| 126 self._session_id = response['sessionId'] | 134 self._session_id = response['sessionId'] |
| 127 self.capabilities = self._UnwrapValue(response['value']) | 135 self.capabilities = self._UnwrapValue(response['value']) |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 return self.ExecuteCommand(Command.GET_LOG, {'type': type}) | 347 return self.ExecuteCommand(Command.GET_LOG, {'type': type}) |
| 340 | 348 |
| 341 def GetAvailableLogTypes(self): | 349 def GetAvailableLogTypes(self): |
| 342 return self.ExecuteCommand(Command.GET_AVAILABLE_LOG_TYPES) | 350 return self.ExecuteCommand(Command.GET_AVAILABLE_LOG_TYPES) |
| 343 | 351 |
| 344 def IsAutoReporting(self): | 352 def IsAutoReporting(self): |
| 345 return self.ExecuteCommand(Command.IS_AUTO_REPORTING) | 353 return self.ExecuteCommand(Command.IS_AUTO_REPORTING) |
| 346 | 354 |
| 347 def SetAutoReporting(self, enabled): | 355 def SetAutoReporting(self, enabled): |
| 348 self.ExecuteCommand(Command.SET_AUTO_REPORTING, {'enabled': enabled}) | 356 self.ExecuteCommand(Command.SET_AUTO_REPORTING, {'enabled': enabled}) |
| OLD | NEW |