| 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 sys | 5 import sys |
| 6 import platform | 6 import platform |
| 7 | 7 |
| 8 import command_executor | 8 import command_executor |
| 9 from command_executor import Command | 9 from command_executor import Command |
| 10 from webelement import WebElement | 10 from webelement import WebElement |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 class ChromeDriver(object): | 66 class ChromeDriver(object): |
| 67 """Starts and controls a single Chrome instance on this machine.""" | 67 """Starts and controls a single Chrome instance on this machine.""" |
| 68 | 68 |
| 69 def __init__(self, server_url, chrome_binary=None, android_package=None, | 69 def __init__(self, server_url, chrome_binary=None, android_package=None, |
| 70 android_activity=None, android_process=None, | 70 android_activity=None, android_process=None, |
| 71 android_use_running_app=None, chrome_switches=None, | 71 android_use_running_app=None, chrome_switches=None, |
| 72 chrome_extensions=None, chrome_log_path=None, | 72 chrome_extensions=None, chrome_log_path=None, |
| 73 debugger_address=None, logging_prefs=None, | 73 debugger_address=None, logging_prefs=None, |
| 74 mobile_emulation=None, experimental_options=None, | 74 mobile_emulation=None, experimental_options=None, |
| 75 download_dir=None, network_connection=None): | 75 download_dir=None, page_load_strategy=None, |
| 76 network_connection=None): |
| 76 self._executor = command_executor.CommandExecutor(server_url) | 77 self._executor = command_executor.CommandExecutor(server_url) |
| 77 | 78 |
| 78 options = {} | 79 options = {} |
| 79 | 80 |
| 80 if experimental_options: | 81 if experimental_options: |
| 81 assert isinstance(experimental_options, dict) | 82 assert isinstance(experimental_options, dict) |
| 82 options = experimental_options.copy() | 83 options = experimental_options.copy() |
| 83 | 84 |
| 84 if android_package: | 85 if android_package: |
| 85 options['androidPackage'] = android_package | 86 options['androidPackage'] = android_package |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 options['prefs']['download'] = {} | 138 options['prefs']['download'] = {} |
| 138 options['prefs']['download']['default_directory'] = download_dir | 139 options['prefs']['download']['default_directory'] = download_dir |
| 139 | 140 |
| 140 params = { | 141 params = { |
| 141 'desiredCapabilities': { | 142 'desiredCapabilities': { |
| 142 'chromeOptions': options, | 143 'chromeOptions': options, |
| 143 'loggingPrefs': logging_prefs | 144 'loggingPrefs': logging_prefs |
| 144 } | 145 } |
| 145 } | 146 } |
| 146 | 147 |
| 148 if page_load_strategy: |
| 149 assert type(page_load_strategy) is str |
| 150 params['desiredCapabilities']['pageLoadingStrategy'] = page_load_strategy |
| 151 |
| 147 if network_connection: | 152 if network_connection: |
| 148 params['desiredCapabilities']['networkConnectionEnabled'] = ( | 153 params['desiredCapabilities']['networkConnectionEnabled'] = ( |
| 149 network_connection) | 154 network_connection) |
| 150 | 155 |
| 151 response = self._ExecuteCommand(Command.NEW_SESSION, params) | 156 response = self._ExecuteCommand(Command.NEW_SESSION, params) |
| 152 self._session_id = response['sessionId'] | 157 self._session_id = response['sessionId'] |
| 153 self.capabilities = self._UnwrapValue(response['value']) | 158 self.capabilities = self._UnwrapValue(response['value']) |
| 154 | 159 |
| 155 def _WrapValue(self, value): | 160 def _WrapValue(self, value): |
| 156 """Wrap value from client side for chromedriver side.""" | 161 """Wrap value from client side for chromedriver side.""" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 418 |
| 414 def GetNetworkConnection(self): | 419 def GetNetworkConnection(self): |
| 415 return self.ExecuteCommand(Command.GET_NETWORK_CONNECTION) | 420 return self.ExecuteCommand(Command.GET_NETWORK_CONNECTION) |
| 416 | 421 |
| 417 def DeleteNetworkConditions(self): | 422 def DeleteNetworkConditions(self): |
| 418 self.ExecuteCommand(Command.DELETE_NETWORK_CONDITIONS) | 423 self.ExecuteCommand(Command.DELETE_NETWORK_CONDITIONS) |
| 419 | 424 |
| 420 def SetNetworkConnection(self, connection_type): | 425 def SetNetworkConnection(self, connection_type): |
| 421 params = {'parameters': {'type': connection_type}} | 426 params = {'parameters': {'type': connection_type}} |
| 422 self.ExecuteCommand(Command.SET_NETWORK_CONNECTION, params) | 427 self.ExecuteCommand(Command.SET_NETWORK_CONNECTION, params) |
| OLD | NEW |