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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 status = response['status'] | 55 status = response['status'] |
56 msg = response['value']['message'] | 56 msg = response['value']['message'] |
57 return exception_class_map.get(status, ChromeDriverException)(msg) | 57 return exception_class_map.get(status, ChromeDriverException)(msg) |
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 chrome_switches=None, chrome_extensions=None, | 65 chrome_switches=None, chrome_extensions=None, |
65 chrome_log_path=None, debugger_address=None, | 66 chrome_log_path=None, debugger_address=None, |
66 browser_log_level=None): | 67 browser_log_level=None): |
67 self._executor = command_executor.CommandExecutor(server_url) | 68 self._executor = command_executor.CommandExecutor(server_url) |
68 | 69 |
69 options = {} | 70 options = {} |
70 if android_package: | 71 if android_package: |
71 options['androidPackage'] = android_package | 72 options['androidPackage'] = android_package |
| 73 if android_activity: |
| 74 options['androidActivity'] = android_activity |
| 75 if android_process: |
| 76 options['androidProcess'] = android_process |
72 elif chrome_binary: | 77 elif chrome_binary: |
73 options['binary'] = chrome_binary | 78 options['binary'] = chrome_binary |
74 | 79 |
75 if chrome_switches: | 80 if chrome_switches: |
76 assert type(chrome_switches) is list | 81 assert type(chrome_switches) is list |
77 options['args'] = chrome_switches | 82 options['args'] = chrome_switches |
78 | 83 |
79 if chrome_extensions: | 84 if chrome_extensions: |
80 assert type(chrome_extensions) is list | 85 assert type(chrome_extensions) is list |
81 options['extensions'] = chrome_extensions | 86 options['extensions'] = chrome_extensions |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 301 |
297 def Quit(self): | 302 def Quit(self): |
298 """Quits the browser and ends the session.""" | 303 """Quits the browser and ends the session.""" |
299 self.ExecuteCommand(Command.QUIT) | 304 self.ExecuteCommand(Command.QUIT) |
300 | 305 |
301 def GetLog(self, type): | 306 def GetLog(self, type): |
302 return self.ExecuteCommand(Command.GET_LOG, {'type': type}) | 307 return self.ExecuteCommand(Command.GET_LOG, {'type': type}) |
303 | 308 |
304 def GetAvailableLogTypes(self): | 309 def GetAvailableLogTypes(self): |
305 return self.ExecuteCommand(Command.GET_AVAILABLE_LOG_TYPES) | 310 return self.ExecuteCommand(Command.GET_AVAILABLE_LOG_TYPES) |
OLD | NEW |