| Index: chrome/test/webdriver/test/chromedriver.py
|
| diff --git a/chrome/test/webdriver/test/chromedriver.py b/chrome/test/webdriver/test/chromedriver.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..73f708e27bb8e26ce6735232368cd405445bcf16
|
| --- /dev/null
|
| +++ b/chrome/test/webdriver/test/chromedriver.py
|
| @@ -0,0 +1,118 @@
|
| +# Copyright 2008-2009 WebDriver committers
|
| +# Copyright 2008-2009 Google Inc.
|
| +#
|
| +# Licensed under the Apache License, Version 2.0 (the "License");
|
| +# you may not use this file except in compliance with the License.
|
| +# You may obtain a copy of the License at
|
| +#
|
| +# http://www.apache.org/licenses/LICENSE-2.0
|
| +#
|
| +# Unless required by applicable law or agreed to in writing, software
|
| +# distributed under the License is distributed on an "AS IS" BASIS,
|
| +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| +# See the License for the specific language governing permissions and
|
| +# limitations under the License.
|
| +
|
| +
|
| +import base64
|
| +import httplib
|
| +from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
|
| +
|
| +class WebDriver(RemoteWebDriver):
|
| + """
|
| + Controls the ChromeDriver and allows you to drive the browser.
|
| +
|
| + You will need to download the ChromeDriver executable from
|
| + http://code.google.com/p/selenium/downloads/list
|
| + """
|
| +
|
| + CHROME_GET_EXTENSIONS = "chrome.getExtensions"
|
| + CHROME_INSTALL_EXTENSION = "chrome.installExtension"
|
| + CHROME_GET_VIEW_HANDLES = "chrome.getViewHandles"
|
| +
|
| + def __init__(self, url, desired_capabilities={}):
|
| + RemoteWebDriver.__init__(self,
|
| + command_executor=url,
|
| + desired_capabilities=desired_capabilities)
|
| +
|
| + # Add custom commands.
|
| + custom_commands = {
|
| + WebDriver.CHROME_GET_EXTENSIONS:
|
| + ('GET', '/session/$sessionId/chrome/extensions'),
|
| + WebDriver.CHROME_INSTALL_EXTENSION:
|
| + ('POST', '/session/$sessionId/chrome/extensions'),
|
| + WebDriver.CHROME_GET_VIEW_HANDLES:
|
| + ('GET', '/session/$sessionId/chrome/views')
|
| + }
|
| + self.command_executor._commands.update(custom_commands)
|
| +
|
| + def get_installed_extensions(self):
|
| + return RemoteWebDriver.execute(self, WebDriver.CHROME_GET_EXTENSIONS)['value']
|
| +
|
| + def install_extension(self, path):
|
| + params = {'path': path}
|
| + id = RemoteWebDriver.execute(self, WebDriver.CHROME_INSTALL_EXTENSION, params)['value']
|
| + return Extension(self, id)
|
| +
|
| + @property
|
| + def views(self):
|
| + return RemoteWebDriver.execute(self, WebDriver.CHROME_GET_VIEW_HANDLES)['value']
|
| +
|
| +class Extension(object):
|
| + """Represents a Chrome extension/app."""
|
| +
|
| + def __init__(self, parent, id):
|
| + self._parent = parent
|
| + self._id = id
|
| +
|
| + @property
|
| + def id(self):
|
| + return self._id
|
| +
|
| + @property
|
| + def name(self):
|
| + pass
|
| +
|
| + @property
|
| + def version(self):
|
| + pass
|
| +
|
| + @property
|
| + def enabled(self):
|
| + pass
|
| +
|
| + @enabled.setter
|
| + def enabled(self, value):
|
| + pass
|
| +
|
| + def uninstall(self):
|
| + pass
|
| +
|
| + def click_browser_action(self):
|
| + pass
|
| +
|
| + def click_page_action(self):
|
| + pass
|
| +
|
| + def is_page_action_visible(self):
|
| + pass
|
| +
|
| + @property
|
| + def popup_window_handle(self):
|
| + pass
|
| +
|
| + # Private Methods
|
| + def _execute(self, command, params=None):
|
| + """Executes a command against the underlying extension.
|
| +
|
| + Args:
|
| + command: The name of the command to _execute as a string.
|
| + params: A dictionary of named parameters to send with the command.
|
| +
|
| + Returns:
|
| + The command's JSON response loaded into a dictionary object.
|
| + """
|
| + if not params:
|
| + params = {}
|
| + params['id'] = self._id
|
| + return self._parent.execute(command, params)
|
|
|