diff --git a/docs/tests.rst b/docs/tests.rst index dd02745d586..28fcd280504 100644 --- a/docs/tests.rst +++ b/docs/tests.rst @@ -283,6 +283,26 @@ version of OSX and a OSX version of XVFB. You can find more details share, please do! +Troubleshooting +--------------- + +**It says "Selenium unavailable."** + + This could mean that Selenium couldn't launch Firefox or can + launch it, but can't connect to it. + + Selenium by default looks for Firefox in "the usual places". + You can explicitly tell it which Firefox binary to use with + the ``SELENIUM_FIREFOX_PATH`` setting. + + For example, in your ``settings_local.py`` file:: + + SELENIUM_FIREFOX_PATH = '/usr/bin/firefox' + + I do this to make sure I'm using Firefox stable for tests + rather than Firefox nightly. + + .. _tests-chapter-qa-test-suite: The QA test suite diff --git a/kitsune/sumo/tests/__init__.py b/kitsune/sumo/tests/__init__.py index 69434c5eb2a..56b91d96d0b 100644 --- a/kitsune/sumo/tests/__init__.py +++ b/kitsune/sumo/tests/__init__.py @@ -13,6 +13,7 @@ from nose.tools import eq_ from selenium import webdriver from selenium.common.exceptions import WebDriverException +from selenium.webdriver.firefox import firefox_binary from test_utils import TestCase as OriginalTestCase from kitsune import sumo @@ -133,7 +134,14 @@ class SeleniumTestCase(LiveServerTestCase): @classmethod def setUpClass(cls): try: - cls.webdriver = webdriver.Firefox() + firefox_path = getattr(settings, 'SELENIUM_FIREFOX_PATH', None) + if firefox_path: + firefox_bin = firefox_binary.FirefoxBinary( + firefox_path=firefox_path) + kwargs = {'firefox_binary': firefox_bin} + else: + kwargs = {} + cls.webdriver = webdriver.Firefox(**kwargs) except (RuntimeError, WebDriverException): cls.skipme = True diff --git a/vendor/packages/selenium/PKG-INFO b/vendor/packages/selenium/PKG-INFO index bd45c2e7322..585b5e033e8 100644 --- a/vendor/packages/selenium/PKG-INFO +++ b/vendor/packages/selenium/PKG-INFO @@ -1,6 +1,6 @@ -Metadata-Version: 1.1 +Metadata-Version: 1.0 Name: selenium -Version: 2.33.0 +Version: 2.35.0 Summary: Python bindings for Selenium Home-page: http://code.google.com/p/selenium/ Author: UNKNOWN @@ -35,10 +35,10 @@ Description: ============ Java Server ----------- - Download the server from http://selenium.googlecode.com/files/selenium-server-standalone-2.33.0.jar + Download the server from http://selenium.googlecode.com/files/selenium-server-standalone-2.35.0.jar :: - java -jar selenium-server-standalone-2.33.0.jar + java -jar selenium-server-standalone-2.35.0.jar Example ======= diff --git a/vendor/packages/selenium/README.txt b/vendor/packages/selenium/README.txt deleted file mode 100644 index 29eafe6c66b..00000000000 --- a/vendor/packages/selenium/README.txt +++ /dev/null @@ -1,36 +0,0 @@ -About Selenium Python Client Driver - -This is a redistribution of the Python client driver that is part -of Selenium RC. - -The reason this redistribution exists is that Python programmers -need an easy way of installing their client driver. - -About Selenium RC - -Selenium RC (aka SRC) is a server that allows you to launch browser sessions and -run Selenium tests in those browsers. Conceptually, the server exposes two main -interfaces to the outside. One is for controlling the browser, the other is to -receive commands that instruct it what to do. This way, independent processes -(think: test programs) can instruct SRC which action to perform on the browser. - -In order to achieve this, the SRC server acts as an intercepting proxy for the -browser. With the initial URL at startup, the browser obtains the Selenium -engine (Selenium Core and other tools). Subsequent calls to open URLs are passed -through SRC which proxies these requests. This way the AUT is received and can -be controlled by Selenium in the browser. Further commands do the usual Selenium -stuff, like asserting page elements, clicking links and filling forms. All these -commands are received by SRC through its command interface from independent -processes. There is a variety of language bindings available (Java, Python, -Ruby, ...) to write programs to this end. - -Additionally to the image provided in the Selenium RC tutorial there is a -(slightly more accessible) overview diagram of the Selenium RC architecture in -the attachment section of this article (selenium-rc-overview.pdf). If you want -to get started with Selenium RC, do read the tutorial. - - Python Client Driver - -More about Selenium Remote Control: - -http://wiki.openqa.org/display/SRC/Home \ No newline at end of file diff --git a/vendor/packages/selenium/ez_setup/README.txt b/vendor/packages/selenium/ez_setup/README.txt deleted file mode 100644 index 9287f5a6405..00000000000 --- a/vendor/packages/selenium/ez_setup/README.txt +++ /dev/null @@ -1,15 +0,0 @@ -This directory exists so that Subversion-based projects can share a single -copy of the ``ez_setup`` bootstrap module for ``setuptools``, and have it -automatically updated in their projects when ``setuptools`` is updated. - -For your convenience, you may use the following svn:externals definition:: - - ez_setup svn://svn.eby-sarna.com/svnroot/ez_setup - -You can set this by executing this command in your project directory:: - - svn propedit svn:externals . - -And then adding the line shown above to the file that comes up for editing. -Then, whenever you update your project, ``ez_setup`` will be updated as well. - diff --git a/vendor/packages/selenium/ez_setup/__init__.py b/vendor/packages/selenium/ez_setup/__init__.py deleted file mode 100644 index d24e845e58d..00000000000 --- a/vendor/packages/selenium/ez_setup/__init__.py +++ /dev/null @@ -1,276 +0,0 @@ -#!python -"""Bootstrap setuptools installation - -If you want to use setuptools in your package's setup.py, just include this -file in the same directory with it, and add this to the top of your setup.py:: - - from ez_setup import use_setuptools - use_setuptools() - -If you want to require a specific version of setuptools, set a download -mirror, or use an alternate download directory, you can do so by supplying -the appropriate options to ``use_setuptools()``. - -This file can also be run as a script to install or upgrade setuptools. -""" -import sys -DEFAULT_VERSION = "0.6c9" -DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3] - -md5_data = { - 'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca', - 'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb', - 'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b', - 'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a', - 'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618', - 'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac', - 'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5', - 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4', - 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c', - 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b', - 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27', - 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277', - 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa', - 'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e', - 'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e', - 'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f', - 'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2', - 'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc', - 'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167', - 'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64', - 'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d', - 'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20', - 'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab', - 'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53', - 'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2', - 'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e', - 'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372', - 'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902', - 'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de', - 'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b', - 'setuptools-0.6c9-py2.3.egg': 'a83c4020414807b496e4cfbe08507c03', - 'setuptools-0.6c9-py2.4.egg': '260a2be2e5388d66bdaee06abec6342a', - 'setuptools-0.6c9-py2.5.egg': 'fe67c3e5a17b12c0e7c541b7ea43a8e6', - 'setuptools-0.6c9-py2.6.egg': 'ca37b1ff16fa2ede6e19383e7b59245a', -} - -import sys, os -try: from hashlib import md5 -except ImportError: from md5 import md5 - -def _validate_md5(egg_name, data): - if egg_name in md5_data: - digest = md5(data).hexdigest() - if digest != md5_data[egg_name]: - print >>sys.stderr, ( - "md5 validation of %s failed! (Possible download problem?)" - % egg_name - ) - sys.exit(2) - return data - -def use_setuptools( - version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, - download_delay=15 -): - """Automatically find/download setuptools and make it available on sys.path - - `version` should be a valid setuptools version number that is available - as an egg for download under the `download_base` URL (which should end with - a '/'). `to_dir` is the directory where setuptools will be downloaded, if - it is not already available. If `download_delay` is specified, it should - be the number of seconds that will be paused before initiating a download, - should one be required. If an older version of setuptools is installed, - this routine will print a message to ``sys.stderr`` and raise SystemExit in - an attempt to abort the calling script. - """ - was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules - def do_download(): - egg = download_setuptools(version, download_base, to_dir, download_delay) - sys.path.insert(0, egg) - import setuptools; setuptools.bootstrap_install_from = egg - try: - import pkg_resources - except ImportError: - return do_download() - try: - pkg_resources.require("setuptools>="+version); return - except pkg_resources.VersionConflict, e: - if was_imported: - print >>sys.stderr, ( - "The required version of setuptools (>=%s) is not available, and\n" - "can't be installed while this script is running. Please install\n" - " a more recent version first, using 'easy_install -U setuptools'." - "\n\n(Currently using %r)" - ) % (version, e.args[0]) - sys.exit(2) - else: - del pkg_resources, sys.modules['pkg_resources'] # reload ok - return do_download() - except pkg_resources.DistributionNotFound: - return do_download() - -def download_setuptools( - version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, - delay = 15 -): - """Download setuptools from a specified location and return its filename - - `version` should be a valid setuptools version number that is available - as an egg for download under the `download_base` URL (which should end - with a '/'). `to_dir` is the directory where the egg will be downloaded. - `delay` is the number of seconds to pause before an actual download attempt. - """ - import urllib2, shutil - egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3]) - url = download_base + egg_name - saveto = os.path.join(to_dir, egg_name) - src = dst = None - if not os.path.exists(saveto): # Avoid repeated downloads - try: - from distutils import log - if delay: - log.warn(""" ---------------------------------------------------------------------------- -This script requires setuptools version %s to run (even to display -help). I will attempt to download it for you (from -%s), but -you may need to enable firewall access for this script first. -I will start the download in %d seconds. - -(Note: if this machine does not have network access, please obtain the file - - %s - -and place it in this directory before rerunning this script.) ----------------------------------------------------------------------------""", - version, download_base, delay, url - ); from time import sleep; sleep(delay) - log.warn("Downloading %s", url) - src = urllib2.urlopen(url) - # Read/write all in one block, so we don't create a corrupt file - # if the download is interrupted. - data = _validate_md5(egg_name, src.read()) - dst = open(saveto,"wb"); dst.write(data) - finally: - if src: src.close() - if dst: dst.close() - return os.path.realpath(saveto) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -def main(argv, version=DEFAULT_VERSION): - """Install or upgrade setuptools and EasyInstall""" - try: - import setuptools - except ImportError: - egg = None - try: - egg = download_setuptools(version, delay=0) - sys.path.insert(0,egg) - from setuptools.command.easy_install import main - return main(list(argv)+[egg]) # we're done here - finally: - if egg and os.path.exists(egg): - os.unlink(egg) - else: - if setuptools.__version__ == '0.0.1': - print >>sys.stderr, ( - "You have an obsolete version of setuptools installed. Please\n" - "remove it from your system entirely before rerunning this script." - ) - sys.exit(2) - - req = "setuptools>="+version - import pkg_resources - try: - pkg_resources.require(req) - except pkg_resources.VersionConflict: - try: - from setuptools.command.easy_install import main - except ImportError: - from easy_install import main - main(list(argv)+[download_setuptools(delay=0)]) - sys.exit(0) # try to force an exit - else: - if argv: - from setuptools.command.easy_install import main - main(argv) - else: - print "Setuptools version",version,"or greater has been installed." - print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' - -def update_md5(filenames): - """Update our built-in md5 registry""" - - import re - - for name in filenames: - base = os.path.basename(name) - f = open(name,'rb') - md5_data[base] = md5(f.read()).hexdigest() - f.close() - - data = [" %r: %r,\n" % it for it in md5_data.items()] - data.sort() - repl = "".join(data) - - import inspect - srcfile = inspect.getsourcefile(sys.modules[__name__]) - f = open(srcfile, 'rb'); src = f.read(); f.close() - - match = re.search("\nmd5_data = {\n([^}]+)}", src) - if not match: - print >>sys.stderr, "Internal error!" - sys.exit(2) - - src = src[:match.start(1)] + repl + src[match.end(1):] - f = open(srcfile,'w') - f.write(src) - f.close() - - -if __name__=='__main__': - if len(sys.argv)>2 and sys.argv[1]=='--md5update': - update_md5(sys.argv[2:]) - else: - main(sys.argv[1:]) - - - - - - diff --git a/vendor/packages/selenium/pip-delete-this-directory.txt b/vendor/packages/selenium/pip-delete-this-directory.txt deleted file mode 100644 index c8883ea99f5..00000000000 --- a/vendor/packages/selenium/pip-delete-this-directory.txt +++ /dev/null @@ -1,5 +0,0 @@ -This file is placed here by pip to indicate the source was put -here by pip. - -Once this package is successfully installed this source code will be -deleted (unless you remove this file). diff --git a/vendor/packages/selenium/pip-egg-info/selenium.egg-info/PKG-INFO b/vendor/packages/selenium/pip-egg-info/selenium.egg-info/PKG-INFO index df4f9ef405b..10c6ce72040 100644 --- a/vendor/packages/selenium/pip-egg-info/selenium.egg-info/PKG-INFO +++ b/vendor/packages/selenium/pip-egg-info/selenium.egg-info/PKG-INFO @@ -1,6 +1,6 @@ -Metadata-Version: 1.0 +Metadata-Version: 1.1 Name: selenium -Version: 2.33.0 +Version: 2.35.0 Summary: Python bindings for Selenium Home-page: http://code.google.com/p/selenium/ Author: UNKNOWN @@ -35,10 +35,10 @@ Description: ============ Java Server ----------- - Download the server from http://selenium.googlecode.com/files/selenium-server-standalone-2.33.0.jar + Download the server from http://selenium.googlecode.com/files/selenium-server-standalone-2.35.0.jar :: - java -jar selenium-server-standalone-2.33.0.jar + java -jar selenium-server-standalone-2.35.0.jar Example ======= diff --git a/vendor/packages/selenium/py/CHANGES b/vendor/packages/selenium/py/CHANGES index 5619caf007d..aa154731279 100644 --- a/vendor/packages/selenium/py/CHANGES +++ b/vendor/packages/selenium/py/CHANGES @@ -1,3 +1,15 @@ +Selenium 2.35 +* Remove duplicate 'get screenshot as file' methods. Add method 'get_screenshot_as_png' +* fixing UnicodeEncodeError on get attribute of webelement + +Selenium 2.34 +* Corrected webdriverbackedselenium session handling. Fixes issue 4283 +* Corrected use of basestring for python 3. Fixes issue 5924 +* Support for Firefox 22 +* Added support for logging from the browser +* corrected proxy handling on FirefoxProfile +* Corrected handling of chrome extensions. Fixes issue 5762 + Selenium 2.33 * getText() ignores elements in the * Adding both official and informal string representations to Color object. diff --git a/vendor/packages/selenium/py/README b/vendor/packages/selenium/py/README index be68aa6ff04..fe1327455df 100644 --- a/vendor/packages/selenium/py/README +++ b/vendor/packages/selenium/py/README @@ -27,10 +27,10 @@ Python Client Java Server ----------- -Download the server from http://selenium.googlecode.com/files/selenium-server-standalone-2.33.0.jar +Download the server from http://selenium.googlecode.com/files/selenium-server-standalone-2.35.0.jar :: - java -jar selenium-server-standalone-2.33.0.jar + java -jar selenium-server-standalone-2.35.0.jar Example ======= diff --git a/vendor/packages/selenium/py/selenium/__init__.py b/vendor/packages/selenium/py/selenium/__init__.py index 40d8768be42..05d5a096f82 100644 --- a/vendor/packages/selenium/py/selenium/__init__.py +++ b/vendor/packages/selenium/py/selenium/__init__.py @@ -16,4 +16,4 @@ from selenium import selenium -__version__ = "2.33.0" +__version__ = "2.35.0" diff --git a/vendor/packages/selenium/py/selenium/common/exceptions.py b/vendor/packages/selenium/py/selenium/common/exceptions.py index 8405a32302b..a580673e85d 100644 --- a/vendor/packages/selenium/py/selenium/common/exceptions.py +++ b/vendor/packages/selenium/py/selenium/common/exceptions.py @@ -13,8 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Exceptions that may happen in all the webdriver code.""" +""" +Exceptions that may happen in all the webdriver code. +""" + class WebDriverException(Exception): + """ + Base webdriver exception. + """ + def __init__(self, msg=None, screen=None, stacktrace=None): self.msg = msg self.screen = screen @@ -31,83 +38,126 @@ def __str__(self): return exception_msg class ErrorInResponseException(WebDriverException): - """An error has occurred on the server side. + """ + Thrown when an error has occurred on the server side. This may happen when communicating with the firefox extension - or the remote driver server.""" + or the remote driver server. + """ def __init__(self, response, msg): WebDriverException.__init__(self, msg) self.response = response class InvalidSwitchToTargetException(WebDriverException): - """The frame or window target to be switched doesn't exist.""" + """ + Thrown when frame or window target to be switched doesn't exist. + """ pass class NoSuchFrameException(InvalidSwitchToTargetException): + """ + Thrown when frame target to be switched doesn't exist. + """ pass class NoSuchWindowException(InvalidSwitchToTargetException): + """ + Thrown when window target to be switched doesn't exist. + """ pass class NoSuchElementException(WebDriverException): - """find_element_by_* can't find the element.""" + """ + Thrown when element could not be found. + """ pass class NoSuchAttributeException(WebDriverException): - """find_element_by_* can't find the element.""" + """ + Thrown when the attribute of element could not be found. + """ pass class StaleElementReferenceException(WebDriverException): - """Indicates that a reference to an element is now "stale" --- the - element no longer appears on the DOM of the page.""" + """ + Thrown when a reference to an element is now "stale". + + Stale means the element no longer appears on the DOM of the page. + """ pass -class InvalidElementStateException(WebDriverException): +class InvalidElementStateException(WebDriverException): + """ + """ pass class UnexpectedAlertPresentException(WebDriverException): + """ + Thrown when an unexpected alert is appeared. + """ pass class NoAlertPresentException(WebDriverException): + """ + Thrown when switching to no presented alert. + """ pass class ElementNotVisibleException(InvalidElementStateException): - """Thrown to indicate that although an element is present on the - DOM, it is not visible, and so is not able to be interacted - with.""" + """ + Thrown when although an element is present on the DOM, + it is not visible, and so is not able to be interacted with. + """ pass class ElementNotSelectableException(InvalidElementStateException): + """ + Thrown when trying to select an unselectable element. + """ pass class InvalidCookieDomainException(WebDriverException): - """Thrown when attempting to add a cookie under a different domain - than the current URL.""" + """ + Thrown when attempting to add a cookie under a different domain + than the current URL. + """ pass class UnableToSetCookieException(WebDriverException): - """Thrown when a driver fails to set a cookie.""" + """ + Thrown when a driver fails to set a cookie. + """ pass class RemoteDriverServerException(WebDriverException): + """ + """ pass class TimeoutException(WebDriverException): - """Thrown when a command does not complete in enough time.""" + """ + Thrown when a command does not complete in enough time. + """ pass class MoveTargetOutOfBoundsException(WebDriverException): - """Indicates that the target provided to the actions move() method is invalid""" + """ + Thrown when the target provided to the `ActionsChains` move() + method is invalid, i.e. out of document. + """ pass class UnexpectedTagNameException(WebDriverException): - """Thrown when a support class did not get an expected web element""" + """ + Thrown when a support class did not get an expected web element. + """ pass class InvalidSelectorException(NoSuchElementException): - """ Thrown when the selector which is used to find an element does not return + """ + Thrown when the selector which is used to find an element does not return a WebElement. Currently this only happens when the selector is an xpath - expression is used which is either syntactically invalid (i.e. it is not a + expression and it is either syntactically invalid (i.e. it is not a xpath expression) or the expression does not select WebElements (e.g. "count(//input)"). """ @@ -115,11 +165,13 @@ class InvalidSelectorException(NoSuchElementException): class ImeNotAvailableException(WebDriverException): """ - Indicates that IME support is not available. This exception is thrown for every IME-related + Thrown when IME support is not available. This exception is thrown for every IME-related method call if IME support is not available on the machine. """ pass class ImeActivationFailedException(WebDriverException): - """ Indicates that activating an IME engine has failed. """ + """ + Thrown when activating an IME engine has failed. + """ pass diff --git a/vendor/packages/selenium/py/selenium/selenium.py b/vendor/packages/selenium/py/selenium/selenium.py index 2e89ef4060c..a7870b317dc 100644 --- a/vendor/packages/selenium/py/selenium/selenium.py +++ b/vendor/packages/selenium/py/selenium/selenium.py @@ -193,8 +193,7 @@ def start(self, browserConfigurationOptions=None, driver=None): if browserConfigurationOptions: start_args.append(browserConfigurationOptions) if driver: - id = driver.desired_capabilities['webdriver.remote.sessionid'] - start_args.append('webdriver.remote.sessionid=%s' % id) + start_args.append('webdriver.remote.sessionid=%s' % driver.session_id) result = self.get_string("getNewBrowserSession", start_args) try: self.sessionId = result diff --git a/vendor/packages/selenium/py/selenium/webdriver/__init__.py b/vendor/packages/selenium/py/selenium/webdriver/__init__.py index af95b7c918d..f150e549b98 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/__init__.py +++ b/vendor/packages/selenium/py/selenium/webdriver/__init__.py @@ -28,4 +28,4 @@ from .common.touch_actions import TouchActions from .common.proxy import Proxy -__version__ = '2.33.0' +__version__ = '2.35.0' diff --git a/vendor/packages/selenium/py/selenium/webdriver/chrome/options.py b/vendor/packages/selenium/py/selenium/webdriver/chrome/options.py index 13126b09d49..ec57eff2c35 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/chrome/options.py +++ b/vendor/packages/selenium/py/selenium/webdriver/chrome/options.py @@ -72,7 +72,7 @@ def extensions(self): """ encoded_extensions = [] for ext in self._extension_files: - file_ = open(ext) + file_ = open(ext, 'rb') # Should not use base64.encodestring() which inserts newlines every # 76 characters (per RFC 1521). Chromedriver has to remove those # unnecessary newlines before decoding, causing performance hit. diff --git a/vendor/packages/selenium/py/selenium/webdriver/common/action_chains.py b/vendor/packages/selenium/py/selenium/webdriver/common/action_chains.py index acea8ac0b57..c8d70647808 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/common/action_chains.py +++ b/vendor/packages/selenium/py/selenium/webdriver/common/action_chains.py @@ -14,7 +14,7 @@ # limitations under the License. """ -The ActionChains implementation +The ActionChains implementation, """ from selenium.webdriver.remote.command import Command from selenium.webdriver.common.keys import Keys @@ -22,8 +22,8 @@ class ActionChains(object): """ Generate user actions. - All actions are stored in the ActionChains object. Call perform() to fire - stored actions. + All actions are stored in the ActionChains object. + Call perform() to fire stored actions. """ def __init__(self, driver): @@ -96,7 +96,8 @@ def double_click(self, on_element=None): return self def drag_and_drop(self, source, target): - """Holds down the left mouse button on the source element, + """ + Holds down the left mouse button on the source element, then moves to the target element and releases the mouse button. :Args: @@ -110,7 +111,7 @@ def drag_and_drop(self, source, target): def drag_and_drop_by_offset(self, source, xoffset, yoffset): """ Holds down the left mouse button on the source element, - then moves to the target element and releases the mouse button. + then moves to the target offset and releases the mouse button. :Args: - source: The element to mouse down. @@ -123,12 +124,13 @@ def drag_and_drop_by_offset(self, source, xoffset, yoffset): return self def key_down(self, value, element=None): - """Sends a key press only, without releasing it. - Should only be used with modifier keys (Control, Alt and Shift). + """ + Sends a key press only, without releasing it. + Should only be used with modifier keys (Control, Alt and Shift). :Args: - - key: The modifier key to send. Values are defined in Keys class. - - target: The element to send keys. + - value: The modifier key to send. Values are defined in `Keys` class. + - element: The element to send keys. If None, sends a key to current focused element. """ typing = [] @@ -154,8 +156,8 @@ def key_up(self, value, element=None): Releases a modifier key. :Args: - - key: The modifier key to send. Values are defined in Keys class. - - target: The element to send keys. + - value: The modifier key to send. Values are defined in Keys class. + - element: The element to send keys. If None, sends a key to current focused element. """ typing = [] @@ -204,7 +206,7 @@ def move_to_element(self, to_element): def move_to_element_with_offset(self, to_element, xoffset, yoffset): """ Move the mouse by an offset of the specificed element. - Offsets are relative to the top-left corner of the element. + Offsets are relative to the top-left corner of the element. :Args: - to_element: The element to move to. @@ -220,10 +222,11 @@ def move_to_element_with_offset(self, to_element, xoffset, yoffset): def release(self, on_element=None): """ - Releasing a held mouse button. + Releasing a held mouse button on an element. :Args: - on_element: The element to mouse up. + If None, releases on current mouse position. """ if on_element: self.move_to_element(on_element) self._actions.append(lambda: @@ -231,7 +234,8 @@ def release(self, on_element=None): return self def send_keys(self, *keys_to_send): - """Sends keys to current focused element. + """ + Sends keys to current focused element. :Args: - keys_to_send: The keys to send. diff --git a/vendor/packages/selenium/py/selenium/webdriver/common/alert.py b/vendor/packages/selenium/py/selenium/webdriver/common/alert.py index 711f09cf84c..d176ec89272 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/common/alert.py +++ b/vendor/packages/selenium/py/selenium/webdriver/common/alert.py @@ -13,27 +13,51 @@ #See the License for the specific language governing permissions and #limitations under the License. +""" +The Alert implementation. +""" + from selenium.webdriver.remote.command import Command class Alert(object): + """ + Allows to work wit alerts. + """ def __init__(self, driver): + """ + Creates a new Alert. + + :Args: + - driver: The WebDriver instance which performs user actions. + """ self.driver = driver @property def text(self): - """ Gets the text of the Alert """ + """ + Gets the text of the Alert. + """ return self.driver.execute(Command.GET_ALERT_TEXT)["value"] def dismiss(self): - """ Dismisses the alert available """ + """ + Dismisses the alert available. + """ self.driver.execute(Command.DISMISS_ALERT) def accept(self): - """ Accepts the alert available """ + """ + Accepts the alert available. + """ self.driver.execute(Command.ACCEPT_ALERT) def send_keys(self, keysToSend): - """ Send Keys to the Alert """ + """ + Send Keys to the Alert. + + :Args: + - keysToSend: The text to be sent to Alert. + """ self.driver.execute(Command.SET_ALERT_VALUE, {'text': keysToSend}) diff --git a/vendor/packages/selenium/py/selenium/webdriver/common/by.py b/vendor/packages/selenium/py/selenium/webdriver/common/by.py index b54ca729f25..6d61ec30a7e 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/common/by.py +++ b/vendor/packages/selenium/py/selenium/webdriver/common/by.py @@ -13,8 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +The By implemention. +""" class By(object): + """ + Set of supported locator strategies. + """ + ID = "id" XPATH = "xpath" LINK_TEXT = "link text" diff --git a/vendor/packages/selenium/py/selenium/webdriver/common/desired_capabilities.py b/vendor/packages/selenium/py/selenium/webdriver/common/desired_capabilities.py index e59b5c5c5bc..1bc031610fb 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/common/desired_capabilities.py +++ b/vendor/packages/selenium/py/selenium/webdriver/common/desired_capabilities.py @@ -13,7 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +The Desired Capabilities implementation. +""" + class DesiredCapabilities(object): + """ + Set of supported desired capabilities. + """ FIREFOX = { "browserName": "firefox", diff --git a/vendor/packages/selenium/py/selenium/webdriver/common/html5/__init__.py b/vendor/packages/selenium/py/selenium/webdriver/common/html5/__init__.py index e69de29bb2d..e1e59108b2c 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/common/html5/__init__.py +++ b/vendor/packages/selenium/py/selenium/webdriver/common/html5/__init__.py @@ -0,0 +1,14 @@ +# Copyright 2008-2013 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. diff --git a/vendor/packages/selenium/py/selenium/webdriver/common/html5/application_cache.py b/vendor/packages/selenium/py/selenium/webdriver/common/html5/application_cache.py index 4c5986ea22e..cda47b6d049 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/common/html5/application_cache.py +++ b/vendor/packages/selenium/py/selenium/webdriver/common/html5/application_cache.py @@ -1,6 +1,12 @@ +""" +The ApplicationCache implementaion. +""" + from selenium.webdriver.remote.command import Command class ApplicationCache(object): + """ + """ UNCACHED = 0 IDLE = 1 @@ -10,8 +16,17 @@ class ApplicationCache(object): OBSOLETE = 5 def __init__(self, driver): + """ + Creates a new Aplication Cache. + + :Args: + - driver: The WebDriver instance which performs user actions. + """ self.driver = driver @property def status(self): + """ + Returns a current status of application cache. + """ return self.driver.execute(Command.GET_APP_CACHE_STATUS)['value'] diff --git a/vendor/packages/selenium/py/selenium/webdriver/common/keys.py b/vendor/packages/selenium/py/selenium/webdriver/common/keys.py index 14d9e09bc7c..8a4d1a0d292 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/common/keys.py +++ b/vendor/packages/selenium/py/selenium/webdriver/common/keys.py @@ -13,9 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +The Keys implementation. +""" + from __future__ import unicode_literals class Keys(object): + """ + Set of special keys codes. + """ NULL = '\ue000' CANCEL = '\ue001' # ^break diff --git a/vendor/packages/selenium/py/selenium/webdriver/common/proxy.py b/vendor/packages/selenium/py/selenium/webdriver/common/proxy.py index 3c3ca9ecb4d..8cf090aee38 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/common/proxy.py +++ b/vendor/packages/selenium/py/selenium/webdriver/common/proxy.py @@ -1,9 +1,22 @@ +""" +The Proxy implementation. +""" + class ProxyTypeFactory: + """ + Factory for proxy types. + """ + @staticmethod def make(ff_value, string): return {'ff_value': ff_value, 'string': string} class ProxyType: + """ + Set of possible types of proxy. Proxy type has 2 property - + 'ff_value' is value of Firefox profile preference, + 'string' is id of proxy type. + """ DIRECT = ProxyTypeFactory.make(0, 'DIRECT') # Direct connection, no proxy (default on Windows). MANUAL = ProxyTypeFactory.make(1, 'MANUAL') # Manual proxy settings (e.g., for httpProxy). @@ -11,10 +24,13 @@ class ProxyType: RESERVED_1 = ProxyTypeFactory.make(3, 'RESERVED1') # Never used. AUTODETECT = ProxyTypeFactory.make(4, 'AUTODETECT') # Proxy autodetection (presumably with WPAD). SYSTEM = ProxyTypeFactory.make(5, 'SYSTEM') # Use system settings (default on Linux). - UNSPECIFIED = ProxyTypeFactory.make(6, 'UNSPECIFIED') + UNSPECIFIED = ProxyTypeFactory.make(6, 'UNSPECIFIED') # Not initialized (for internal use). class Proxy(object): + """ + Proxy contains information about proxy type and necessary proxy settings. + """ proxyType = ProxyType.UNSPECIFIED autodetect = False @@ -25,6 +41,12 @@ class Proxy(object): sslProxy = '' def __init__(self, raw=None): + """ + Creates a new Proxy. + + :Args: + - raw: raw proxy data. If None, default class values are used. + """ if raw is not None: if 'proxyType' in raw and raw['proxyType'] is not None: self.proxy_type = raw['proxyType'] @@ -43,73 +65,136 @@ def __init__(self, raw=None): @property def proxy_type(self): + """ + Returns proxy type as `ProxyType`. + """ return self.proxyType @proxy_type.setter def proxy_type(self, value): - self._verify_proxy_type_compatilibily(ProxyType.AUTODETECT) + """ + Sets proxy type. + + :Args: + - value: Te proxy type. + """ + self._verify_proxy_type_compatilibily(value) self.proxyType = value @property def auto_detect(self): + """ + Returns autodect setting. + """ return self.autodetect @auto_detect.setter def auto_detect(self, value): + """ + Sets autodetect setting. + + :Args: + - value: The autodetect value. + """ if isinstance(value, bool): if self.autodetect is not value: self._verify_proxy_type_compatilibily(ProxyType.AUTODETECT) self.proxyType = ProxyType.AUTODETECT self.autodetect = value else: - raise ValueError("value needs to be a boolean") + raise ValueError("Autodetect proxy value needs to be a boolean") @property def ftp_proxy(self): + """ + Returns ftp proxy setting. + """ return self.ftpProxy @ftp_proxy.setter def ftp_proxy(self, value): + """ + Sets ftp proxy setting. + + :Args: + - value: The ftp proxy value. + """ self._verify_proxy_type_compatilibily(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.ftpProxy = value @property def http_proxy(self): + """ + Returns http proxy setting. + """ return self.httpProxy @http_proxy.setter def http_proxy(self, value): + """ + Sets http proxy setting. + + :Args: + - value: The http proxy value. + """ self._verify_proxy_type_compatilibily(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.httpProxy = value @property def no_proxy(self): + """ + Returns noproxy setting. + """ return self.noProxy @no_proxy.setter def no_proxy(self, value): + """ + Sets noproxy setting. + + :Args: + - value: The noproxy value. + """ self._verify_proxy_type_compatilibily(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.noProxy = value @property def proxy_autoconfig_url(self): + """ + Returns proxy autoconfig url setting. + """ return self.proxyAutoconfigUrl @proxy_autoconfig_url.setter def proxy_autoconfig_url(self, value): + """ + Sets proxy autoconfig url setting. + + :Args: + - value: The proxy autoconfig url value. + """ self._verify_proxy_type_compatilibily(ProxyType.PAC) self.proxyType = ProxyType.PAC self.proxyAutoconfigUrl = value @property def ssl_proxy(self): + """ + Returns https proxy setting. + """ return self.sslProxy @ssl_proxy.setter def ssl_proxy(self, value): + """ + Sets https proxy setting. + + :Args: + - value: The https proxy value. + """ self._verify_proxy_type_compatilibily(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.sslProxy = value @@ -121,6 +206,12 @@ def _verify_proxy_type_compatilibily(self, compatibleProxy): def add_to_capabilities(self, capabilities): + """ + Adds proxy information as capability in specified capabilties. + + :Args: + - capabilities: The capabilities to which proxy will be added. + """ proxy_caps = {} proxy_caps['proxyType'] = self.proxyType['string'] if self.autodetect: @@ -133,4 +224,6 @@ def add_to_capabilities(self, capabilities): proxy_caps['proxyAutoconfigUrl'] = self.proxyAutoconfigUrl if self.sslProxy: proxy_caps['sslProxy'] = self.sslProxy + if self.noProxy: + proxy_caps['noProxy'] = self.noProxy capabilities['proxy'] = proxy_caps diff --git a/vendor/packages/selenium/py/selenium/webdriver/common/touch_actions.py b/vendor/packages/selenium/py/selenium/webdriver/common/touch_actions.py index 257e050d134..d23a5f0c944 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/common/touch_actions.py +++ b/vendor/packages/selenium/py/selenium/webdriver/common/touch_actions.py @@ -1,5 +1,5 @@ -"""" -Touch Actions implementation +""" +The Touch Actions implementation """ from selenium.webdriver.remote.command import Command @@ -14,8 +14,9 @@ def __init__(self, driver): """ Creates a new TouchActions object. - Args: - -driver: The WebDriver instance, which must be touchscreen enabled. + :Args: + - driver: The WebDriver instance which performs user actions. + It should be with touchscreen enabled. """ self._driver = driver self._actions = [] @@ -31,8 +32,8 @@ def tap(self, on_element): """ Taps on a given element. - Args: - -element: The element to tap. + :Args: + - on_element: The element to tap. """ self._actions.append(lambda: self._driver.execute(Command.SINGLE_TAP, {'element': on_element.id})) @@ -42,8 +43,8 @@ def double_tap(self, on_element): """ Double taps on a given element. - Args: - -element: The element to tap. + :Args: + - on_element: The element to tap. """ self._actions.append(lambda: self._driver.execute(Command.DOUBLE_TAP, {'element': on_element.id})) @@ -51,11 +52,11 @@ def double_tap(self, on_element): def tap_and_hold(self, xcoord, ycoord): """ - Tap and hold a given element. + Touch down at given coordinates. - Args: - -xcoord: X Coordinates. - -ycoord: Y Coordinates. + :Args: + - xcoord: X Coordinate to touch down. + - ycoord: Y Coordinate to touch down. """ self._actions.append(lambda: self._driver.execute(Command.TOUCH_DOWN, { @@ -67,9 +68,9 @@ def move(self, xcoord, ycoord): """ Move held tap to specified location. - Args: - -xcoord: X Coordinates. - -ycoord: Y Coordinates. + :Args: + - xcoord: X Coordinate to move. + - ycoord: Y Coordinate to move. """ self._actions.append(lambda: self._driver.execute(Command.TOUCH_MOVE, { @@ -79,11 +80,11 @@ def move(self, xcoord, ycoord): def release(self, xcoord, ycoord): """ - Release previously issued tap and hold command, at specified location. + Release previously issued tap 'and hold' command at specified location. - Args: - -xcoord: X Coordinates. - -ycoord: Y Coordinates. + :Args: + - xcoord: X Coordinate to release. + - ycoord: Y Coordinate to release. """ self._actions.append(lambda: self._driver.execute(Command.TOUCH_UP, { @@ -95,9 +96,9 @@ def scroll(self, xoffset, yoffset): """ Touch and scroll, moving by xoffset and yoffset. - Args: - -xoffset: X offset to move to. - -yoffset: Y offset to move to. + :Args: + - xoffset: X offset to scroll to. + - yoffset: Y offset to scroll to. """ self._actions.append(lambda: self._driver.execute(Command.TOUCH_SCROLL, { @@ -109,10 +110,10 @@ def scroll_from_element(self, on_element, xoffset, yoffset): """ Touch and scroll starting at on_element, moving by xoffset and yoffset. - Args: - -on_element: Element where scroll starts. - -xoffset: X offset to move to. - -yoffset: Y offset to move to. + :Args: + - on_element: The element where scroll starts. + - xoffset: X offset to scroll to. + - yoffset: Y offset to scroll to. """ self._actions.append(lambda: self._driver.execute(Command.TOUCH_SCROLL, { @@ -125,8 +126,8 @@ def long_press(self, on_element): """ Long press on an element. - Args: - -on_element: The element to long press. + :Args: + - on_element: The element to long press. """ self._actions.append(lambda: self._driver.execute(Command.LONG_PRESS, {'element': on_element.id})) @@ -136,25 +137,26 @@ def flick(self, xspeed, yspeed): """ Flicks, starting anywhere on the screen. - Args: - -xspeed: The X speed in pixels per second. - -yspeed: The Y speed in pixels per second. + :Args: + - xspeed: The X speed in pixels per second. + - yspeed: The Y speed in pixels per second. """ self._actions.append(lambda: self._driver.execute(Command.FLICK, { - 'xSpeed': xspeed, - 'ySpeed': yspeed})) + 'xspeed': xspeed, + 'yspeed': yspeed})) return self def flick_element(self, on_element, xoffset, yoffset, speed): """ - Flick starting at on_element, and moving by the xoffset and yoffset. + Flick starting at on_element, and moving by the xoffset and yoffset + with specified speed. - Args: - -on_element: Flick will start at center of element. - -xoffset: X offset to flick to. - -yoffset: Y offset to flick to. - -speed: Pixels per second to flick. + :Args: + - on_element: Flick will start at center of element. + - xoffset: X offset to flick to. + - yoffset: Y offset to flick to. + - speed: Pixels per second to flick. """ self._actions.append(lambda: self._driver.execute(Command.FLICK, { diff --git a/vendor/packages/selenium/py/selenium/webdriver/common/utils.py b/vendor/packages/selenium/py/selenium/webdriver/common/utils.py index 015e240f5ec..084e3a44aed 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/common/utils.py +++ b/vendor/packages/selenium/py/selenium/webdriver/common/utils.py @@ -12,29 +12,48 @@ # 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. + +""" +The Utils methods. +""" import socket def free_port(): - free_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - free_socket.bind(('127.0.0.1', 0)) - free_socket.listen(5) - port = free_socket.getsockname()[1] - free_socket.close() - return port + """ + Determines a free port using sockets. + """ + free_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + free_socket.bind(('127.0.0.1', 0)) + free_socket.listen(5) + port = free_socket.getsockname()[1] + free_socket.close() + return port def is_connectable(port): - """Trys to connect to the server to see if it is running.""" - try: - socket_ = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - socket_.settimeout(1) - socket_.connect(("localhost", port)) - socket_.close() - return True - except socket.error: - return False + """ + Tries to connect to the server at port to see if it is running. + + :Args: + - port: The port to connect. + """ + try: + socket_ = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + socket_.settimeout(1) + socket_.connect(("localhost", port)) + socket_.close() + return True + except socket.error: + return False def is_url_connectable(port): + """ + Tries to connect to the HTTP server at /status path + and specified port to see if it responds successfully. + + :Args: + - port: The port to connect. + """ try: from urllib import request as url_request except ImportError: diff --git a/vendor/packages/selenium/py/selenium/webdriver/firefox/firefox_binary.py b/vendor/packages/selenium/py/selenium/webdriver/firefox/firefox_binary.py index 543227aace3..4d430fcf93b 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/firefox/firefox_binary.py +++ b/vendor/packages/selenium/py/selenium/webdriver/firefox/firefox_binary.py @@ -26,8 +26,18 @@ class FirefoxBinary(object): NO_FOCUS_LIBRARY_NAME = "x_ignore_nofocus.so" - def __init__(self, firefox_path=None): + def __init__(self, firefox_path=None, log_file=None): + """ + Creates a new instance of Firefox binary. + + :Args: + - firefox_path - Path to the Firefox executable. By default, it will be detected from the standard locations. + - log_file - A file object to redirect the firefox process output to. It can be sys.stdout. + Please note that with parallel run the output won't be synchronous. + By default, it will be redirected to subprocess.PIPE. + """ self._start_cmd = firefox_path + self._log_file = log_file or PIPE self.command_line = None if self._start_cmd is None: self._start_cmd = self._get_firefox_start_cmd() @@ -69,11 +79,11 @@ def _start_from_profile_path(self, path): for cli in self.command_line: command.append(cli) - Popen(command, stdout=PIPE, stderr=STDOUT, + Popen(command, stdout=self._log_file, stderr=STDOUT, env=self._firefox_env).communicate() command[1] = '-foreground' self.process = Popen( - command, stdout=PIPE, stderr=STDOUT, + command, stdout=self._log_file, stderr=STDOUT, env=self._firefox_env) def _get_firefox_output(self): diff --git a/vendor/packages/selenium/py/selenium/webdriver/firefox/firefox_profile.py b/vendor/packages/selenium/py/selenium/webdriver/firefox/firefox_profile.py index 96073006fe4..9886d669e4b 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/firefox/firefox_profile.py +++ b/vendor/packages/selenium/py/selenium/webdriver/firefox/firefox_profile.py @@ -242,7 +242,7 @@ def set_proxy(self, proxy): self._set_manual_proxy_preference("ftp", proxy.ftp_proxy) self._set_manual_proxy_preference("http", proxy.http_proxy) self._set_manual_proxy_preference("ssl", proxy.ssl_proxy) - elif proxy.proxy_type is ProxyType.AUTODETECT: + elif proxy.proxy_type is ProxyType.PAC: self.set_preference("network.proxy.autoconfig_url", proxy.proxy_autoconfig_url) #Private Methods @@ -253,14 +253,15 @@ def _santise_pref(self, item): return False else: return item + def _set_manual_proxy_preference(self, key, setting): if setting is None or setting is '': return host_details = setting.split(":") - self.set_preference("network.proxy.%s" % key, host_details[1][2:]) + self.set_preference("network.proxy.%s" % key, host_details[0]) if len(host_details) > 1: - self.set_preference("network.proxy.%s_port" % key, int(host_details[2])) + self.set_preference("network.proxy.%s_port" % key, int(host_details[1])) def _create_tempfolder(self): """ diff --git a/vendor/packages/selenium/py/selenium/webdriver/firefox/webdriver.py b/vendor/packages/selenium/py/selenium/webdriver/firefox/webdriver.py index 6f9b801656d..8f5f862764e 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/firefox/webdriver.py +++ b/vendor/packages/selenium/py/selenium/webdriver/firefox/webdriver.py @@ -28,7 +28,6 @@ from selenium.webdriver.firefox.firefox_profile import FirefoxProfile from selenium.webdriver.remote.command import Command from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver -from selenium.webdriver.remote.webelement import WebElement class WebDriver(RemoteWebDriver): @@ -62,10 +61,6 @@ def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30, desired_capabilities=capabilities) self._is_remote = False - def create_web_element(self, element_id): - """Override from RemoteWebDriver to use firefox.WebElement.""" - return WebElement(self, element_id) - def quit(self): """Quits the driver and close every associated window.""" try: diff --git a/vendor/packages/selenium/py/selenium/webdriver/firefox/webdriver.xpi b/vendor/packages/selenium/py/selenium/webdriver/firefox/webdriver.xpi index 41f849cd818..40252cb0c1e 100644 Binary files a/vendor/packages/selenium/py/selenium/webdriver/firefox/webdriver.xpi and b/vendor/packages/selenium/py/selenium/webdriver/firefox/webdriver.xpi differ diff --git a/vendor/packages/selenium/py/selenium/webdriver/remote/command.py b/vendor/packages/selenium/py/selenium/webdriver/remote/command.py index 43fe28dd0bc..e4176a31374 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/remote/command.py +++ b/vendor/packages/selenium/py/selenium/webdriver/remote/command.py @@ -88,6 +88,8 @@ class Command(object): SET_SCRIPT_TIMEOUT = "setScriptTimeout" SET_TIMEOUTS = "setTimeouts" MAXIMIZE_WINDOW = "windowMaximize" + GET_LOG = "getLog" + GET_AVAILABLE_LOG_TYPES = "getAvailableLogTypes" #Alerts DISMISS_ALERT = "dismissAlert" diff --git a/vendor/packages/selenium/py/selenium/webdriver/remote/errorhandler.py b/vendor/packages/selenium/py/selenium/webdriver/remote/errorhandler.py index e6849011aff..ffffc64d1d8 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/remote/errorhandler.py +++ b/vendor/packages/selenium/py/selenium/webdriver/remote/errorhandler.py @@ -32,6 +32,12 @@ from selenium.common.exceptions import WebDriverException from selenium.common.exceptions import MoveTargetOutOfBoundsException +try: + basestring +except NameError: # Python 3.x + basestring = str + + class ErrorCode(object): """ Error codes defined in the WebDriver wire protocol. diff --git a/vendor/packages/selenium/py/selenium/webdriver/remote/remote_connection.py b/vendor/packages/selenium/py/selenium/webdriver/remote/remote_connection.py index 21a94dd8327..f49fd5bf653 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/remote/remote_connection.py +++ b/vendor/packages/selenium/py/selenium/webdriver/remote/remote_connection.py @@ -327,6 +327,10 @@ def __init__(self, remote_server_addr): ('DELETE', '/session/$sessionId/session_storage'), Command.GET_SESSION_STORAGE_SIZE: ('GET','/session/$sessionId/session_storage/size'), + Command.GET_LOG: + ('POST','/session/$sessionId/log'), + Command.GET_AVAILABLE_LOG_TYPES: + ('GET','/session/$sessionId/log/types'), } def execute(self, command, params): diff --git a/vendor/packages/selenium/py/selenium/webdriver/remote/webdriver.py b/vendor/packages/selenium/py/selenium/webdriver/remote/webdriver.py index 45240014099..320be7dae4a 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/remote/webdriver.py +++ b/vendor/packages/selenium/py/selenium/webdriver/remote/webdriver.py @@ -709,15 +709,27 @@ def get_screenshot_as_file(self, filename): :Usage: driver.get_screenshot_as_file('/Screenshots/foo.png') """ - png = self.execute(Command.SCREENSHOT)['value'] + png = self.get_screenshot_as_png() try: with open(filename, 'wb') as f: - f.write(base64.b64decode(png.encode('ascii'))) + f.write(png) except IOError: return False - del png + finally: + del png return True + save_screenshot = get_screenshot_as_file + + def get_screenshot_as_png(self): + """ + Gets the screenshot of the current window as a binary data. + + :Usage: + driver.get_screenshot_as_png() + """ + return base64.b64decode(self.get_screenshot_as_base64().encode('ascii')) + def get_screenshot_as_base64(self): """ Gets the screenshot of the current window as a base64 encoded string @@ -739,7 +751,7 @@ def set_window_size(self, width, height, windowHandle='current'): :Usage: driver.set_window_size(800,600) """ - self.execute(Command.SET_WINDOW_SIZE, {'width': width, 'height': height, + self.execute(Command.SET_WINDOW_SIZE, {'width': int(width), 'height': int(height), 'windowHandle': windowHandle}) def get_window_size(self, windowHandle='current'): @@ -763,7 +775,7 @@ def set_window_position(self, x, y, windowHandle='current'): :Usage: driver.set_window_position(0,0) """ - self.execute(Command.SET_WINDOW_POSITION, {'x': x, 'y': y, + self.execute(Command.SET_WINDOW_POSITION, {'x': int(x), 'y': int(y), 'windowHandle': windowHandle}) def get_window_position(self, windowHandle='current'): @@ -812,18 +824,27 @@ def application_cache(self): """ Returns a ApplicationCache Object to interact with the browser app cache""" return ApplicationCache(self) - def save_screenshot(self, filename): + @property + def log_types(self): """ - Gets the screenshot of the current window. Returns False if there is - any IOError, else returns True. Use full paths in your filename. + Gets a list of the available log types + + :Usage: + driver.log_types """ - png = self.execute(Command.SCREENSHOT)['value'] - try: - f = open(filename, 'wb') - f.write(base64.b64decode(png.encode('ascii'))) - f.close() - except IOError: - return False - finally: - del png - return True + return self.execute(Command.GET_AVAILABLE_LOG_TYPES)['value'] + + def get_log(self, log_type): + """ + Gets the log for a given log type + + :Args: + - log_type: type of log that which will be returned + + :Usage: + driver.get_log('browser') + driver.get_log('driver') + driver.get_log('client') + driver.get_log('server') + """ + return self.execute(Command.GET_LOG, {'type': log_type})['value'] diff --git a/vendor/packages/selenium/py/selenium/webdriver/remote/webelement.py b/vendor/packages/selenium/py/selenium/webdriver/remote/webelement.py index fb789519ff7..0df87c87a40 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/remote/webelement.py +++ b/vendor/packages/selenium/py/selenium/webdriver/remote/webelement.py @@ -69,7 +69,7 @@ def get_attribute(self, name): attributeValue = None else: attributeValue = resp['value'] - if type(resp['value']) is bool: + if attributeValue.lower() in ('true', 'false'): attributeValue = attributeValue.lower() return attributeValue diff --git a/vendor/packages/selenium/py/selenium/webdriver/support/select.py b/vendor/packages/selenium/py/selenium/webdriver/support/select.py index 5bd103a05b9..58ffae87658 100644 --- a/vendor/packages/selenium/py/selenium/webdriver/support/select.py +++ b/vendor/packages/selenium/py/selenium/webdriver/support/select.py @@ -90,13 +90,14 @@ def select_by_index(self, index): - index - The option at this index will be selected """ match = str(index) + matched = False for opt in self.options: if opt.get_attribute("index") == match: self._setSelected(opt) if not self.is_multiple: return - match = True - if match != True: + matched = True + if not matched: raise NoSuchElementException("Could not locate element with index %d" % index) def select_by_visible_text(self, text): diff --git a/vendor/packages/selenium/selenium.egg-info/PKG-INFO b/vendor/packages/selenium/selenium.egg-info/PKG-INFO index bd45c2e7322..585b5e033e8 100644 --- a/vendor/packages/selenium/selenium.egg-info/PKG-INFO +++ b/vendor/packages/selenium/selenium.egg-info/PKG-INFO @@ -1,6 +1,6 @@ -Metadata-Version: 1.1 +Metadata-Version: 1.0 Name: selenium -Version: 2.33.0 +Version: 2.35.0 Summary: Python bindings for Selenium Home-page: http://code.google.com/p/selenium/ Author: UNKNOWN @@ -35,10 +35,10 @@ Description: ============ Java Server ----------- - Download the server from http://selenium.googlecode.com/files/selenium-server-standalone-2.33.0.jar + Download the server from http://selenium.googlecode.com/files/selenium-server-standalone-2.35.0.jar :: - java -jar selenium-server-standalone-2.33.0.jar + java -jar selenium-server-standalone-2.35.0.jar Example ======= diff --git a/vendor/packages/selenium/setup.py b/vendor/packages/selenium/setup.py index ee67fb5f70c..723fe617027 100644 --- a/vendor/packages/selenium/setup.py +++ b/vendor/packages/selenium/setup.py @@ -28,7 +28,7 @@ setup_args = { 'cmdclass':{'install': install}, 'name':'selenium', - 'version':"2.33.0", + 'version':"2.35.0", 'description':'Python bindings for Selenium', 'long_description':open(join(abspath(dirname(__file__)), "py", "README")).read(), 'url':'http://code.google.com/p/selenium/', diff --git a/vendor/packages/selenium/src/selenium.py b/vendor/packages/selenium/src/selenium.py deleted file mode 100644 index 66fc45571b1..00000000000 --- a/vendor/packages/selenium/src/selenium.py +++ /dev/null @@ -1,2071 +0,0 @@ - -""" -Copyright 2006 ThoughtWorks, 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. -""" -__docformat__ = "restructuredtext en" - -# This file has been automatically generated via XSL - -import httplib -import urllib -import re - -class selenium: - """ - Defines an object that runs Selenium commands. - - Element Locators - ~~~~~~~~~~~~~~~~ - - Element Locators tell Selenium which HTML element a command refers to. - The format of a locator is: - - \ *locatorType*\ **=**\ \ *argument* - - - We support the following strategies for locating elements: - - - * \ **identifier**\ =\ *id*: - Select the element with the specified @id attribute. If no match is - found, select the first element whose @name attribute is \ *id*. - (This is normally the default; see below.) - * \ **id**\ =\ *id*: - Select the element with the specified @id attribute. - * \ **name**\ =\ *name*: - Select the first element with the specified @name attribute. - - * username - * name=username - - - The name may optionally be followed by one or more \ *element-filters*, separated from the name by whitespace. If the \ *filterType* is not specified, \ **value**\ is assumed. - - * name=flavour value=chocolate - - - * \ **dom**\ =\ *javascriptExpression*: - - Find an element by evaluating the specified string. This allows you to traverse the HTML Document Object - Model using JavaScript. Note that you must not return a value in this string; simply make it the last expression in the block. - - * dom=document.forms['myForm'].myDropdown - * dom=document.images[56] - * dom=function foo() { return document.links[1]; }; foo(); - - - * \ **xpath**\ =\ *xpathExpression*: - Locate an element using an XPath expression. - - * xpath=//img[@alt='The image alt text'] - * xpath=//table[@id='table1']//tr[4]/td[2] - * xpath=//a[contains(@href,'#id1')] - * xpath=//a[contains(@href,'#id1')]/@class - * xpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../td - * xpath=//input[@name='name2' and @value='yes'] - * xpath=//\*[text()="right"] - - - * \ **link**\ =\ *textPattern*: - Select the link (anchor) element which contains text matching the - specified \ *pattern*. - - * link=The link text - - - * \ **css**\ =\ *cssSelectorSyntax*: - Select the element using css selectors. Please refer to CSS2 selectors, CSS3 selectors for more information. You can also check the TestCssLocators test in the selenium test suite for an example of usage, which is included in the downloaded selenium core package. - - * css=a[href="#id3"] - * css=span#firstChild + span - - - Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, :only-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after). - - * \ **ui**\ =\ *uiSpecifierString*: - Locate an element by resolving the UI specifier string to another locator, and evaluating it. See the Selenium UI-Element Reference for more details. - - * ui=loginPages::loginButton() - * ui=settingsPages::toggle(label=Hide Email) - * ui=forumPages::postBody(index=2)//a[2] - - - - - - Without an explicit locator prefix, Selenium uses the following default - strategies: - - - * \ **dom**\ , for locators starting with "document." - * \ **xpath**\ , for locators starting with "//" - * \ **identifier**\ , otherwise - - Element Filters - ~~~~~~~~~~~~~~~ - - Element filters can be used with a locator to refine a list of candidate elements. They are currently used only in the 'name' element-locator. - - Filters look much like locators, ie. - - \ *filterType*\ **=**\ \ *argument* - - Supported element-filters are: - - \ **value=**\ \ *valuePattern* - - - Matches elements based on their values. This is particularly useful for refining a list of similarly-named toggle-buttons. - - \ **index=**\ \ *index* - - - Selects a single element based on its position in the list (offset from zero). - - String-match Patterns - ~~~~~~~~~~~~~~~~~~~~~ - - Various Pattern syntaxes are available for matching string values: - - - * \ **glob:**\ \ *pattern*: - Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a - kind of limited regular-expression syntax typically used in command-line - shells. In a glob pattern, "\*" represents any sequence of characters, and "?" - represents any single character. Glob patterns match against the entire - string. - * \ **regexp:**\ \ *regexp*: - Match a string using a regular-expression. The full power of JavaScript - regular-expressions is available. - * \ **regexpi:**\ \ *regexpi*: - Match a string using a case-insensitive regular-expression. - * \ **exact:**\ \ *string*: - - Match a string exactly, verbatim, without any of that fancy wildcard - stuff. - - - - If no pattern prefix is specified, Selenium assumes that it's a "glob" - pattern. - - - - For commands that return multiple values (such as verifySelectOptions), - the string being matched is a comma-separated list of the return values, - where both commas and backslashes in the values are backslash-escaped. - When providing a pattern, the optional matching syntax (i.e. glob, - regexp, etc.) is specified once, as usual, at the beginning of the - pattern. - - - """ - -### This part is hard-coded in the XSL - def __init__(self, host, port, browserStartCommand, browserURL): - self.host = host - self.port = port - self.browserStartCommand = browserStartCommand - self.browserURL = browserURL - self.sessionId = None - self.extensionJs = "" - - def setExtensionJs(self, extensionJs): - self.extensionJs = extensionJs - - def start(self): - result = self.get_string("getNewBrowserSession", [self.browserStartCommand, self.browserURL, self.extensionJs]) - try: - self.sessionId = result - except ValueError: - raise Exception, result - - def stop(self): - self.do_command("testComplete", []) - self.sessionId = None - - def do_command(self, verb, args): - conn = httplib.HTTPConnection(self.host, self.port) - body = u'cmd=' + urllib.quote_plus(unicode(verb).encode('utf-8')) - for i in range(len(args)): - body += '&' + unicode(i+1) + '=' + urllib.quote_plus(unicode(args[i]).encode('utf-8')) - if (None != self.sessionId): - body += "&sessionId=" + unicode(self.sessionId) - headers = {"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"} - conn.request("POST", "/selenium-server/driver/", body, headers) - - response = conn.getresponse() - #print response.status, response.reason - data = unicode(response.read(), "UTF-8") - result = response.reason - #print "Selenium Result: " + repr(data) + "\n\n" - if (not data.startswith('OK')): - raise Exception, data - return data - - def get_string(self, verb, args): - result = self.do_command(verb, args) - return result[3:] - - def get_string_array(self, verb, args): - csv = self.get_string(verb, args) - token = "" - tokens = [] - escape = False - for i in range(len(csv)): - letter = csv[i] - if (escape): - token = token + letter - escape = False - continue - if (letter == '\\'): - escape = True - elif (letter == ','): - tokens.append(token) - token = "" - else: - token = token + letter - tokens.append(token) - return tokens - - def get_number(self, verb, args): - # Is there something I need to do here? - return self.get_string(verb, args) - - def get_number_array(self, verb, args): - # Is there something I need to do here? - return self.get_string_array(verb, args) - - def get_boolean(self, verb, args): - boolstr = self.get_string(verb, args) - if ("true" == boolstr): - return True - if ("false" == boolstr): - return False - raise ValueError, "result is neither 'true' nor 'false': " + boolstr - - def get_boolean_array(self, verb, args): - boolarr = self.get_string_array(verb, args) - for i in range(len(boolarr)): - if ("true" == boolstr): - boolarr[i] = True - continue - if ("false" == boolstr): - boolarr[i] = False - continue - raise ValueError, "result is neither 'true' nor 'false': " + boolarr[i] - return boolarr - - - -### From here on, everything's auto-generated from XML - - - def click(self,locator): - """ - Clicks on a link, button, checkbox or radio button. If the click action - causes a new page to load (like a link usually does), call - waitForPageToLoad. - - 'locator' is an element locator - """ - self.do_command("click", [locator,]) - - - def double_click(self,locator): - """ - Double clicks on a link, button, checkbox or radio button. If the double click action - causes a new page to load (like a link usually does), call - waitForPageToLoad. - - 'locator' is an element locator - """ - self.do_command("doubleClick", [locator,]) - - - def context_menu(self,locator): - """ - Simulates opening the context menu for the specified element (as might happen if the user "right-clicked" on the element). - - 'locator' is an element locator - """ - self.do_command("contextMenu", [locator,]) - - - def click_at(self,locator,coordString): - """ - Clicks on a link, button, checkbox or radio button. If the click action - causes a new page to load (like a link usually does), call - waitForPageToLoad. - - 'locator' is an element locator - 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator. - """ - self.do_command("clickAt", [locator,coordString,]) - - - def double_click_at(self,locator,coordString): - """ - Doubleclicks on a link, button, checkbox or radio button. If the action - causes a new page to load (like a link usually does), call - waitForPageToLoad. - - 'locator' is an element locator - 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator. - """ - self.do_command("doubleClickAt", [locator,coordString,]) - - - def context_menu_at(self,locator,coordString): - """ - Simulates opening the context menu for the specified element (as might happen if the user "right-clicked" on the element). - - 'locator' is an element locator - 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator. - """ - self.do_command("contextMenuAt", [locator,coordString,]) - - - def fire_event(self,locator,eventName): - """ - Explicitly simulate an event, to trigger the corresponding "on\ *event*" - handler. - - 'locator' is an element locator - 'eventName' is the event name, e.g. "focus" or "blur" - """ - self.do_command("fireEvent", [locator,eventName,]) - - - def focus(self,locator): - """ - Move the focus to the specified element; for example, if the element is an input field, move the cursor to that field. - - 'locator' is an element locator - """ - self.do_command("focus", [locator,]) - - - def key_press(self,locator,keySequence): - """ - Simulates a user pressing and releasing a key. - - 'locator' is an element locator - 'keySequence' is Either be a string("\" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", "\119". - """ - self.do_command("keyPress", [locator,keySequence,]) - - - def shift_key_down(self): - """ - Press the shift key and hold it down until doShiftUp() is called or a new page is loaded. - - """ - self.do_command("shiftKeyDown", []) - - - def shift_key_up(self): - """ - Release the shift key. - - """ - self.do_command("shiftKeyUp", []) - - - def meta_key_down(self): - """ - Press the meta key and hold it down until doMetaUp() is called or a new page is loaded. - - """ - self.do_command("metaKeyDown", []) - - - def meta_key_up(self): - """ - Release the meta key. - - """ - self.do_command("metaKeyUp", []) - - - def alt_key_down(self): - """ - Press the alt key and hold it down until doAltUp() is called or a new page is loaded. - - """ - self.do_command("altKeyDown", []) - - - def alt_key_up(self): - """ - Release the alt key. - - """ - self.do_command("altKeyUp", []) - - - def control_key_down(self): - """ - Press the control key and hold it down until doControlUp() is called or a new page is loaded. - - """ - self.do_command("controlKeyDown", []) - - - def control_key_up(self): - """ - Release the control key. - - """ - self.do_command("controlKeyUp", []) - - - def key_down(self,locator,keySequence): - """ - Simulates a user pressing a key (without releasing it yet). - - 'locator' is an element locator - 'keySequence' is Either be a string("\" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", "\119". - """ - self.do_command("keyDown", [locator,keySequence,]) - - - def key_up(self,locator,keySequence): - """ - Simulates a user releasing a key. - - 'locator' is an element locator - 'keySequence' is Either be a string("\" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", "\119". - """ - self.do_command("keyUp", [locator,keySequence,]) - - - def mouse_over(self,locator): - """ - Simulates a user hovering a mouse over the specified element. - - 'locator' is an element locator - """ - self.do_command("mouseOver", [locator,]) - - - def mouse_out(self,locator): - """ - Simulates a user moving the mouse pointer away from the specified element. - - 'locator' is an element locator - """ - self.do_command("mouseOut", [locator,]) - - - def mouse_down(self,locator): - """ - Simulates a user pressing the left mouse button (without releasing it yet) on - the specified element. - - 'locator' is an element locator - """ - self.do_command("mouseDown", [locator,]) - - - def mouse_down_right(self,locator): - """ - Simulates a user pressing the right mouse button (without releasing it yet) on - the specified element. - - 'locator' is an element locator - """ - self.do_command("mouseDownRight", [locator,]) - - - def mouse_down_at(self,locator,coordString): - """ - Simulates a user pressing the left mouse button (without releasing it yet) at - the specified location. - - 'locator' is an element locator - 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator. - """ - self.do_command("mouseDownAt", [locator,coordString,]) - - - def mouse_down_right_at(self,locator,coordString): - """ - Simulates a user pressing the right mouse button (without releasing it yet) at - the specified location. - - 'locator' is an element locator - 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator. - """ - self.do_command("mouseDownRightAt", [locator,coordString,]) - - - def mouse_up(self,locator): - """ - Simulates the event that occurs when the user releases the mouse button (i.e., stops - holding the button down) on the specified element. - - 'locator' is an element locator - """ - self.do_command("mouseUp", [locator,]) - - - def mouse_up_right(self,locator): - """ - Simulates the event that occurs when the user releases the right mouse button (i.e., stops - holding the button down) on the specified element. - - 'locator' is an element locator - """ - self.do_command("mouseUpRight", [locator,]) - - - def mouse_up_at(self,locator,coordString): - """ - Simulates the event that occurs when the user releases the mouse button (i.e., stops - holding the button down) at the specified location. - - 'locator' is an element locator - 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator. - """ - self.do_command("mouseUpAt", [locator,coordString,]) - - - def mouse_up_right_at(self,locator,coordString): - """ - Simulates the event that occurs when the user releases the right mouse button (i.e., stops - holding the button down) at the specified location. - - 'locator' is an element locator - 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator. - """ - self.do_command("mouseUpRightAt", [locator,coordString,]) - - - def mouse_move(self,locator): - """ - Simulates a user pressing the mouse button (without releasing it yet) on - the specified element. - - 'locator' is an element locator - """ - self.do_command("mouseMove", [locator,]) - - - def mouse_move_at(self,locator,coordString): - """ - Simulates a user pressing the mouse button (without releasing it yet) on - the specified element. - - 'locator' is an element locator - 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator. - """ - self.do_command("mouseMoveAt", [locator,coordString,]) - - - def type(self,locator,value): - """ - Sets the value of an input field, as though you typed it in. - - - Can also be used to set the value of combo boxes, check boxes, etc. In these cases, - value should be the value of the option selected, not the visible text. - - - 'locator' is an element locator - 'value' is the value to type - """ - self.do_command("type", [locator,value,]) - - - def type_keys(self,locator,value): - """ - Simulates keystroke events on the specified element, as though you typed the value key-by-key. - - - This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string; - this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events. - - Unlike the simple "type" command, which forces the specified value into the page directly, this command - may or may not have any visible effect, even in cases where typing keys would normally have a visible effect. - For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in - the field. - - In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to - send the keystroke events corresponding to what you just typed. - - - 'locator' is an element locator - 'value' is the value to type - """ - self.do_command("typeKeys", [locator,value,]) - - - def set_speed(self,value): - """ - Set execution speed (i.e., set the millisecond length of a delay which will follow each selenium operation). By default, there is no such delay, i.e., - the delay is 0 milliseconds. - - 'value' is the number of milliseconds to pause after operation - """ - self.do_command("setSpeed", [value,]) - - - def get_speed(self): - """ - Get execution speed (i.e., get the millisecond length of the delay following each selenium operation). By default, there is no such delay, i.e., - the delay is 0 milliseconds. - - See also setSpeed. - - """ - return self.get_string("getSpeed", []) - - - def check(self,locator): - """ - Check a toggle-button (checkbox/radio) - - 'locator' is an element locator - """ - self.do_command("check", [locator,]) - - - def uncheck(self,locator): - """ - Uncheck a toggle-button (checkbox/radio) - - 'locator' is an element locator - """ - self.do_command("uncheck", [locator,]) - - - def select(self,selectLocator,optionLocator): - """ - Select an option from a drop-down using an option locator. - - - - Option locators provide different ways of specifying options of an HTML - Select element (e.g. for selecting a specific option, or for asserting - that the selected option satisfies a specification). There are several - forms of Select Option Locator. - - - * \ **label**\ =\ *labelPattern*: - matches options based on their labels, i.e. the visible text. (This - is the default.) - - * label=regexp:^[Oo]ther - - - * \ **value**\ =\ *valuePattern*: - matches options based on their values. - - * value=other - - - * \ **id**\ =\ *id*: - - matches options based on their ids. - - * id=option1 - - - * \ **index**\ =\ *index*: - matches an option based on its index (offset from zero). - - * index=2 - - - - - - If no option locator prefix is provided, the default behaviour is to match on \ **label**\ . - - - - 'selectLocator' is an element locator identifying a drop-down menu - 'optionLocator' is an option locator (a label by default) - """ - self.do_command("select", [selectLocator,optionLocator,]) - - - def add_selection(self,locator,optionLocator): - """ - Add a selection to the set of selected options in a multi-select element using an option locator. - - @see #doSelect for details of option locators - - 'locator' is an element locator identifying a multi-select box - 'optionLocator' is an option locator (a label by default) - """ - self.do_command("addSelection", [locator,optionLocator,]) - - - def remove_selection(self,locator,optionLocator): - """ - Remove a selection from the set of selected options in a multi-select element using an option locator. - - @see #doSelect for details of option locators - - 'locator' is an element locator identifying a multi-select box - 'optionLocator' is an option locator (a label by default) - """ - self.do_command("removeSelection", [locator,optionLocator,]) - - - def remove_all_selections(self,locator): - """ - Unselects all of the selected options in a multi-select element. - - 'locator' is an element locator identifying a multi-select box - """ - self.do_command("removeAllSelections", [locator,]) - - - def submit(self,formLocator): - """ - Submit the specified form. This is particularly useful for forms without - submit buttons, e.g. single-input "Search" forms. - - 'formLocator' is an element locator for the form you want to submit - """ - self.do_command("submit", [formLocator,]) - - - def open(self,url): - """ - Opens an URL in the test frame. This accepts both relative and absolute - URLs. - - The "open" command waits for the page to load before proceeding, - ie. the "AndWait" suffix is implicit. - - \ *Note*: The URL must be on the same domain as the runner HTML - due to security restrictions in the browser (Same Origin Policy). If you - need to open an URL on another domain, use the Selenium Server to start a - new browser session on that domain. - - 'url' is the URL to open; may be relative or absolute - """ - self.do_command("open", [url,]) - - - def open_window(self,url,windowID): - """ - Opens a popup window (if a window with that ID isn't already open). - After opening the window, you'll need to select it using the selectWindow - command. - - - This command can also be a useful workaround for bug SEL-339. In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example). - In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using - an empty (blank) url, like this: openWindow("", "myFunnyWindow"). - - - 'url' is the URL to open, which can be blank - 'windowID' is the JavaScript window ID of the window to select - """ - self.do_command("openWindow", [url,windowID,]) - - - def select_window(self,windowID): - """ - Selects a popup window using a window locator; once a popup window has been selected, all - commands go to that window. To select the main window again, use null - as the target. - - - - - Window locators provide different ways of specifying the window object: - by title, by internal JavaScript "name," or by JavaScript variable. - - - * \ **title**\ =\ *My Special Window*: - Finds the window using the text that appears in the title bar. Be careful; - two windows can share the same title. If that happens, this locator will - just pick one. - - * \ **name**\ =\ *myWindow*: - Finds the window using its internal JavaScript "name" property. This is the second - parameter "windowName" passed to the JavaScript method window.open(url, windowName, windowFeatures, replaceFlag) - (which Selenium intercepts). - - * \ **var**\ =\ *variableName*: - Some pop-up windows are unnamed (anonymous), but are associated with a JavaScript variable name in the current - application window, e.g. "window.foo = window.open(url);". In those cases, you can open the window using - "var=foo". - - - - - If no window locator prefix is provided, we'll try to guess what you mean like this: - - 1.) if windowID is null, (or the string "null") then it is assumed the user is referring to the original window instantiated by the browser). - - 2.) if the value of the "windowID" parameter is a JavaScript variable name in the current application window, then it is assumed - that this variable contains the return value from a call to the JavaScript window.open() method. - - 3.) Otherwise, selenium looks in a hash it maintains that maps string names to window "names". - - 4.) If \ *that* fails, we'll try looping over all of the known windows to try to find the appropriate "title". - Since "title" is not necessarily unique, this may have unexpected behavior. - - If you're having trouble figuring out the name of a window that you want to manipulate, look at the Selenium log messages - which identify the names of windows created via window.open (and therefore intercepted by Selenium). You will see messages - like the following for each window as it is opened: - - ``debug: window.open call intercepted; window ID (which you can use with selectWindow()) is "myNewWindow"`` - - In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example). - (This is bug SEL-339.) In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using - an empty (blank) url, like this: openWindow("", "myFunnyWindow"). - - - 'windowID' is the JavaScript window ID of the window to select - """ - self.do_command("selectWindow", [windowID,]) - - - def select_pop_up(self,windowID): - """ - Simplifies the process of selecting a popup window (and does not offer - functionality beyond what ``selectWindow()`` already provides). - - * If ``windowID`` is either not specified, or specified as - "null", the first non-top window is selected. The top window is the one - that would be selected by ``selectWindow()`` without providing a - ``windowID`` . This should not be used when more than one popup - window is in play. - * Otherwise, the window will be looked up considering - ``windowID`` as the following in order: 1) the "name" of the - window, as specified to ``window.open()``; 2) a javascript - variable which is a reference to a window; and 3) the title of the - window. This is the same ordered lookup performed by - ``selectWindow`` . - - - - 'windowID' is an identifier for the popup window, which can take on a number of different meanings - """ - self.do_command("selectPopUp", [windowID,]) - - - def deselect_pop_up(self): - """ - Selects the main window. Functionally equivalent to using - ``selectWindow()`` and specifying no value for - ``windowID``. - - """ - self.do_command("deselectPopUp", []) - - - def select_frame(self,locator): - """ - Selects a frame within the current window. (You may invoke this command - multiple times to select nested frames.) To select the parent frame, use - "relative=parent" as a locator; to select the top frame, use "relative=top". - You can also select a frame by its 0-based index number; select the first frame with - "index=0", or the third frame with "index=2". - - - You may also use a DOM expression to identify the frame you want directly, - like this: ``dom=frames["main"].frames["subframe"]`` - - - 'locator' is an element locator identifying a frame or iframe - """ - self.do_command("selectFrame", [locator,]) - - - def get_whether_this_frame_match_frame_expression(self,currentFrameString,target): - """ - Determine whether current/locator identify the frame containing this running code. - - - This is useful in proxy injection mode, where this code runs in every - browser frame and window, and sometimes the selenium server needs to identify - the "current" frame. In this case, when the test calls selectFrame, this - routine is called for each frame to figure out which one has been selected. - The selected frame will return true, while all others will return false. - - - 'currentFrameString' is starting frame - 'target' is new frame (which might be relative to the current one) - """ - return self.get_boolean("getWhetherThisFrameMatchFrameExpression", [currentFrameString,target,]) - - - def get_whether_this_window_match_window_expression(self,currentWindowString,target): - """ - Determine whether currentWindowString plus target identify the window containing this running code. - - - This is useful in proxy injection mode, where this code runs in every - browser frame and window, and sometimes the selenium server needs to identify - the "current" window. In this case, when the test calls selectWindow, this - routine is called for each window to figure out which one has been selected. - The selected window will return true, while all others will return false. - - - 'currentWindowString' is starting window - 'target' is new window (which might be relative to the current one, e.g., "_parent") - """ - return self.get_boolean("getWhetherThisWindowMatchWindowExpression", [currentWindowString,target,]) - - - def wait_for_pop_up(self,windowID,timeout): - """ - Waits for a popup window to appear and load up. - - 'windowID' is the JavaScript window "name" of the window that will appear (not the text of the title bar) If unspecified, or specified as "null", this command will wait for the first non-top window to appear (don't rely on this if you are working with multiple popups simultaneously). - 'timeout' is a timeout in milliseconds, after which the action will return with an error. If this value is not specified, the default Selenium timeout will be used. See the setTimeout() command. - """ - self.do_command("waitForPopUp", [windowID,timeout,]) - - - def choose_cancel_on_next_confirmation(self): - """ - - - By default, Selenium's overridden window.confirm() function will - return true, as if the user had manually clicked OK; after running - this command, the next call to confirm() will return false, as if - the user had clicked Cancel. Selenium will then resume using the - default behavior for future confirmations, automatically returning - true (OK) unless/until you explicitly call this command for each - confirmation. - - - - Take note - every time a confirmation comes up, you must - consume it with a corresponding getConfirmation, or else - the next selenium operation will fail. - - - - """ - self.do_command("chooseCancelOnNextConfirmation", []) - - - def choose_ok_on_next_confirmation(self): - """ - - - Undo the effect of calling chooseCancelOnNextConfirmation. Note - that Selenium's overridden window.confirm() function will normally automatically - return true, as if the user had manually clicked OK, so you shouldn't - need to use this command unless for some reason you need to change - your mind prior to the next confirmation. After any confirmation, Selenium will resume using the - default behavior for future confirmations, automatically returning - true (OK) unless/until you explicitly call chooseCancelOnNextConfirmation for each - confirmation. - - - - Take note - every time a confirmation comes up, you must - consume it with a corresponding getConfirmation, or else - the next selenium operation will fail. - - - - """ - self.do_command("chooseOkOnNextConfirmation", []) - - - def answer_on_next_prompt(self,answer): - """ - Instructs Selenium to return the specified answer string in response to - the next JavaScript prompt [window.prompt()]. - - 'answer' is the answer to give in response to the prompt pop-up - """ - self.do_command("answerOnNextPrompt", [answer,]) - - - def go_back(self): - """ - Simulates the user clicking the "back" button on their browser. - - """ - self.do_command("goBack", []) - - - def refresh(self): - """ - Simulates the user clicking the "Refresh" button on their browser. - - """ - self.do_command("refresh", []) - - - def close(self): - """ - Simulates the user clicking the "close" button in the titlebar of a popup - window or tab. - - """ - self.do_command("close", []) - - - def is_alert_present(self): - """ - Has an alert occurred? - - - - This function never throws an exception - - - - """ - return self.get_boolean("isAlertPresent", []) - - - def is_prompt_present(self): - """ - Has a prompt occurred? - - - - This function never throws an exception - - - - """ - return self.get_boolean("isPromptPresent", []) - - - def is_confirmation_present(self): - """ - Has confirm() been called? - - - - This function never throws an exception - - - - """ - return self.get_boolean("isConfirmationPresent", []) - - - def get_alert(self): - """ - Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts. - - - Getting an alert has the same effect as manually clicking OK. If an - alert is generated but you do not consume it with getAlert, the next Selenium action - will fail. - - Under Selenium, JavaScript alerts will NOT pop up a visible alert - dialog. - - Selenium does NOT support JavaScript alerts that are generated in a - page's onload() event handler. In this case a visible dialog WILL be - generated and Selenium will hang until someone manually clicks OK. - - - """ - return self.get_string("getAlert", []) - - - def get_confirmation(self): - """ - Retrieves the message of a JavaScript confirmation dialog generated during - the previous action. - - - - By default, the confirm function will return true, having the same effect - as manually clicking OK. This can be changed by prior execution of the - chooseCancelOnNextConfirmation command. - - - - If an confirmation is generated but you do not consume it with getConfirmation, - the next Selenium action will fail. - - - - NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible - dialog. - - - - NOTE: Selenium does NOT support JavaScript confirmations that are - generated in a page's onload() event handler. In this case a visible - dialog WILL be generated and Selenium will hang until you manually click - OK. - - - - """ - return self.get_string("getConfirmation", []) - - - def get_prompt(self): - """ - Retrieves the message of a JavaScript question prompt dialog generated during - the previous action. - - - Successful handling of the prompt requires prior execution of the - answerOnNextPrompt command. If a prompt is generated but you - do not get/verify it, the next Selenium action will fail. - - NOTE: under Selenium, JavaScript prompts will NOT pop up a visible - dialog. - - NOTE: Selenium does NOT support JavaScript prompts that are generated in a - page's onload() event handler. In this case a visible dialog WILL be - generated and Selenium will hang until someone manually clicks OK. - - - """ - return self.get_string("getPrompt", []) - - - def get_location(self): - """ - Gets the absolute URL of the current page. - - """ - return self.get_string("getLocation", []) - - - def get_title(self): - """ - Gets the title of the current page. - - """ - return self.get_string("getTitle", []) - - - def get_body_text(self): - """ - Gets the entire text of the page. - - """ - return self.get_string("getBodyText", []) - - - def get_value(self,locator): - """ - Gets the (whitespace-trimmed) value of an input field (or anything else with a value parameter). - For checkbox/radio elements, the value will be "on" or "off" depending on - whether the element is checked or not. - - 'locator' is an element locator - """ - return self.get_string("getValue", [locator,]) - - - def get_text(self,locator): - """ - Gets the text of an element. This works for any element that contains - text. This command uses either the textContent (Mozilla-like browsers) or - the innerText (IE-like browsers) of the element, which is the rendered - text shown to the user. - - 'locator' is an element locator - """ - return self.get_string("getText", [locator,]) - - - def highlight(self,locator): - """ - Briefly changes the backgroundColor of the specified element yellow. Useful for debugging. - - 'locator' is an element locator - """ - self.do_command("highlight", [locator,]) - - - def get_eval(self,script): - """ - Gets the result of evaluating the specified JavaScript snippet. The snippet may - have multiple lines, but only the result of the last line will be returned. - - - Note that, by default, the snippet will run in the context of the "selenium" - object itself, so ``this`` will refer to the Selenium object. Use ``window`` to - refer to the window of your application, e.g. ``window.document.getElementById('foo')`` - - If you need to use - a locator to refer to a single element in your application page, you can - use ``this.browserbot.findElement("id=foo")`` where "id=foo" is your locator. - - - 'script' is the JavaScript snippet to run - """ - return self.get_string("getEval", [script,]) - - - def is_checked(self,locator): - """ - Gets whether a toggle-button (checkbox/radio) is checked. Fails if the specified element doesn't exist or isn't a toggle-button. - - 'locator' is an element locator pointing to a checkbox or radio button - """ - return self.get_boolean("isChecked", [locator,]) - - - def get_table(self,tableCellAddress): - """ - Gets the text from a cell of a table. The cellAddress syntax - tableLocator.row.column, where row and column start at 0. - - 'tableCellAddress' is a cell address, e.g. "foo.1.4" - """ - return self.get_string("getTable", [tableCellAddress,]) - - - def get_selected_labels(self,selectLocator): - """ - Gets all option labels (visible text) for selected options in the specified select or multi-select element. - - 'selectLocator' is an element locator identifying a drop-down menu - """ - return self.get_string_array("getSelectedLabels", [selectLocator,]) - - - def get_selected_label(self,selectLocator): - """ - Gets option label (visible text) for selected option in the specified select element. - - 'selectLocator' is an element locator identifying a drop-down menu - """ - return self.get_string("getSelectedLabel", [selectLocator,]) - - - def get_selected_values(self,selectLocator): - """ - Gets all option values (value attributes) for selected options in the specified select or multi-select element. - - 'selectLocator' is an element locator identifying a drop-down menu - """ - return self.get_string_array("getSelectedValues", [selectLocator,]) - - - def get_selected_value(self,selectLocator): - """ - Gets option value (value attribute) for selected option in the specified select element. - - 'selectLocator' is an element locator identifying a drop-down menu - """ - return self.get_string("getSelectedValue", [selectLocator,]) - - - def get_selected_indexes(self,selectLocator): - """ - Gets all option indexes (option number, starting at 0) for selected options in the specified select or multi-select element. - - 'selectLocator' is an element locator identifying a drop-down menu - """ - return self.get_string_array("getSelectedIndexes", [selectLocator,]) - - - def get_selected_index(self,selectLocator): - """ - Gets option index (option number, starting at 0) for selected option in the specified select element. - - 'selectLocator' is an element locator identifying a drop-down menu - """ - return self.get_string("getSelectedIndex", [selectLocator,]) - - - def get_selected_ids(self,selectLocator): - """ - Gets all option element IDs for selected options in the specified select or multi-select element. - - 'selectLocator' is an element locator identifying a drop-down menu - """ - return self.get_string_array("getSelectedIds", [selectLocator,]) - - - def get_selected_id(self,selectLocator): - """ - Gets option element ID for selected option in the specified select element. - - 'selectLocator' is an element locator identifying a drop-down menu - """ - return self.get_string("getSelectedId", [selectLocator,]) - - - def is_something_selected(self,selectLocator): - """ - Determines whether some option in a drop-down menu is selected. - - 'selectLocator' is an element locator identifying a drop-down menu - """ - return self.get_boolean("isSomethingSelected", [selectLocator,]) - - - def get_select_options(self,selectLocator): - """ - Gets all option labels in the specified select drop-down. - - 'selectLocator' is an element locator identifying a drop-down menu - """ - return self.get_string_array("getSelectOptions", [selectLocator,]) - - - def get_attribute(self,attributeLocator): - """ - Gets the value of an element attribute. The value of the attribute may - differ across browsers (this is the case for the "style" attribute, for - example). - - 'attributeLocator' is an element locator followed by an @ sign and then the name of the attribute, e.g. "foo@bar" - """ - return self.get_string("getAttribute", [attributeLocator,]) - - - def is_text_present(self,pattern): - """ - Verifies that the specified text pattern appears somewhere on the rendered page shown to the user. - - 'pattern' is a pattern to match with the text of the page - """ - return self.get_boolean("isTextPresent", [pattern,]) - - - def is_element_present(self,locator): - """ - Verifies that the specified element is somewhere on the page. - - 'locator' is an element locator - """ - return self.get_boolean("isElementPresent", [locator,]) - - - def is_visible(self,locator): - """ - Determines if the specified element is visible. An - element can be rendered invisible by setting the CSS "visibility" - property to "hidden", or the "display" property to "none", either for the - element itself or one if its ancestors. This method will fail if - the element is not present. - - 'locator' is an element locator - """ - return self.get_boolean("isVisible", [locator,]) - - - def is_editable(self,locator): - """ - Determines whether the specified input element is editable, ie hasn't been disabled. - This method will fail if the specified element isn't an input element. - - 'locator' is an element locator - """ - return self.get_boolean("isEditable", [locator,]) - - - def get_all_buttons(self): - """ - Returns the IDs of all buttons on the page. - - - If a given button has no ID, it will appear as "" in this array. - - - """ - return self.get_string_array("getAllButtons", []) - - - def get_all_links(self): - """ - Returns the IDs of all links on the page. - - - If a given link has no ID, it will appear as "" in this array. - - - """ - return self.get_string_array("getAllLinks", []) - - - def get_all_fields(self): - """ - Returns the IDs of all input fields on the page. - - - If a given field has no ID, it will appear as "" in this array. - - - """ - return self.get_string_array("getAllFields", []) - - - def get_attribute_from_all_windows(self,attributeName): - """ - Returns every instance of some attribute from all known windows. - - 'attributeName' is name of an attribute on the windows - """ - return self.get_string_array("getAttributeFromAllWindows", [attributeName,]) - - - def dragdrop(self,locator,movementsString): - """ - deprecated - use dragAndDrop instead - - 'locator' is an element locator - 'movementsString' is offset in pixels from the current location to which the element should be moved, e.g., "+70,-300" - """ - self.do_command("dragdrop", [locator,movementsString,]) - - - def set_mouse_speed(self,pixels): - """ - Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10). - - Setting this value to 0 means that we'll send a "mousemove" event to every single pixel - in between the start location and the end location; that can be very slow, and may - cause some browsers to force the JavaScript to timeout. - - If the mouse speed is greater than the distance between the two dragged objects, we'll - just send one "mousemove" at the start location and then one final one at the end location. - - - 'pixels' is the number of pixels between "mousemove" events - """ - self.do_command("setMouseSpeed", [pixels,]) - - - def get_mouse_speed(self): - """ - Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10). - - """ - return self.get_number("getMouseSpeed", []) - - - def drag_and_drop(self,locator,movementsString): - """ - Drags an element a certain distance and then drops it - - 'locator' is an element locator - 'movementsString' is offset in pixels from the current location to which the element should be moved, e.g., "+70,-300" - """ - self.do_command("dragAndDrop", [locator,movementsString,]) - - - def drag_and_drop_to_object(self,locatorOfObjectToBeDragged,locatorOfDragDestinationObject): - """ - Drags an element and drops it on another element - - 'locatorOfObjectToBeDragged' is an element to be dragged - 'locatorOfDragDestinationObject' is an element whose location (i.e., whose center-most pixel) will be the point where locatorOfObjectToBeDragged is dropped - """ - self.do_command("dragAndDropToObject", [locatorOfObjectToBeDragged,locatorOfDragDestinationObject,]) - - - def window_focus(self): - """ - Gives focus to the currently selected window - - """ - self.do_command("windowFocus", []) - - - def window_maximize(self): - """ - Resize currently selected window to take up the entire screen - - """ - self.do_command("windowMaximize", []) - - - def get_all_window_ids(self): - """ - Returns the IDs of all windows that the browser knows about. - - """ - return self.get_string_array("getAllWindowIds", []) - - - def get_all_window_names(self): - """ - Returns the names of all windows that the browser knows about. - - """ - return self.get_string_array("getAllWindowNames", []) - - - def get_all_window_titles(self): - """ - Returns the titles of all windows that the browser knows about. - - """ - return self.get_string_array("getAllWindowTitles", []) - - - def get_html_source(self): - """ - Returns the entire HTML source between the opening and - closing "html" tags. - - """ - return self.get_string("getHtmlSource", []) - - - def set_cursor_position(self,locator,position): - """ - Moves the text cursor to the specified position in the given input element or textarea. - This method will fail if the specified element isn't an input element or textarea. - - 'locator' is an element locator pointing to an input element or textarea - 'position' is the numerical position of the cursor in the field; position should be 0 to move the position to the beginning of the field. You can also set the cursor to -1 to move it to the end of the field. - """ - self.do_command("setCursorPosition", [locator,position,]) - - - def get_element_index(self,locator): - """ - Get the relative index of an element to its parent (starting from 0). The comment node and empty text node - will be ignored. - - 'locator' is an element locator pointing to an element - """ - return self.get_number("getElementIndex", [locator,]) - - - def is_ordered(self,locator1,locator2): - """ - Check if these two elements have same parent and are ordered siblings in the DOM. Two same elements will - not be considered ordered. - - 'locator1' is an element locator pointing to the first element - 'locator2' is an element locator pointing to the second element - """ - return self.get_boolean("isOrdered", [locator1,locator2,]) - - - def get_element_position_left(self,locator): - """ - Retrieves the horizontal position of an element - - 'locator' is an element locator pointing to an element OR an element itself - """ - return self.get_number("getElementPositionLeft", [locator,]) - - - def get_element_position_top(self,locator): - """ - Retrieves the vertical position of an element - - 'locator' is an element locator pointing to an element OR an element itself - """ - return self.get_number("getElementPositionTop", [locator,]) - - - def get_element_width(self,locator): - """ - Retrieves the width of an element - - 'locator' is an element locator pointing to an element - """ - return self.get_number("getElementWidth", [locator,]) - - - def get_element_height(self,locator): - """ - Retrieves the height of an element - - 'locator' is an element locator pointing to an element - """ - return self.get_number("getElementHeight", [locator,]) - - - def get_cursor_position(self,locator): - """ - Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers. - - - Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to - return the position of the last location of the cursor, even though the cursor is now gone from the page. This is filed as SEL-243. - - This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element. - - 'locator' is an element locator pointing to an input element or textarea - """ - return self.get_number("getCursorPosition", [locator,]) - - - def get_expression(self,expression): - """ - Returns the specified expression. - - - This is useful because of JavaScript preprocessing. - It is used to generate commands like assertExpression and waitForExpression. - - - 'expression' is the value to return - """ - return self.get_string("getExpression", [expression,]) - - - def get_xpath_count(self,xpath): - """ - Returns the number of nodes that match the specified xpath, eg. "//table" would give - the number of tables. - - 'xpath' is the xpath expression to evaluate. do NOT wrap this expression in a 'count()' function; we will do that for you. - """ - return self.get_number("getXpathCount", [xpath,]) - - - def assign_id(self,locator,identifier): - """ - Temporarily sets the "id" attribute of the specified element, so you can locate it in the future - using its ID rather than a slow/complicated XPath. This ID will disappear once the page is - reloaded. - - 'locator' is an element locator pointing to an element - 'identifier' is a string to be used as the ID of the specified element - """ - self.do_command("assignId", [locator,identifier,]) - - - def allow_native_xpath(self,allow): - """ - Specifies whether Selenium should use the native in-browser implementation - of XPath (if any native version is available); if you pass "false" to - this function, we will always use our pure-JavaScript xpath library. - Using the pure-JS xpath library can improve the consistency of xpath - element locators between different browser vendors, but the pure-JS - version is much slower than the native implementations. - - 'allow' is boolean, true means we'll prefer to use native XPath; false means we'll only use JS XPath - """ - self.do_command("allowNativeXpath", [allow,]) - - - def ignore_attributes_without_value(self,ignore): - """ - Specifies whether Selenium will ignore xpath attributes that have no - value, i.e. are the empty string, when using the non-native xpath - evaluation engine. You'd want to do this for performance reasons in IE. - However, this could break certain xpaths, for example an xpath that looks - for an attribute whose value is NOT the empty string. - - The hope is that such xpaths are relatively rare, but the user should - have the option of using them. Note that this only influences xpath - evaluation when using the ajaxslt engine (i.e. not "javascript-xpath"). - - 'ignore' is boolean, true means we'll ignore attributes without value at the expense of xpath "correctness"; false means we'll sacrifice speed for correctness. - """ - self.do_command("ignoreAttributesWithoutValue", [ignore,]) - - - def wait_for_condition(self,script,timeout): - """ - Runs the specified JavaScript snippet repeatedly until it evaluates to "true". - The snippet may have multiple lines, but only the result of the last line - will be considered. - - - Note that, by default, the snippet will be run in the runner's test window, not in the window - of your application. To get the window of your application, you can use - the JavaScript snippet ``selenium.browserbot.getCurrentWindow()``, and then - run your JavaScript in there - - - 'script' is the JavaScript snippet to run - 'timeout' is a timeout in milliseconds, after which this command will return with an error - """ - self.do_command("waitForCondition", [script,timeout,]) - - - def set_timeout(self,timeout): - """ - Specifies the amount of time that Selenium will wait for actions to complete. - - - Actions that require waiting include "open" and the "waitFor\*" actions. - - The default timeout is 30 seconds. - - 'timeout' is a timeout in milliseconds, after which the action will return with an error - """ - self.do_command("setTimeout", [timeout,]) - - - def wait_for_page_to_load(self,timeout): - """ - Waits for a new page to load. - - - You can use this command instead of the "AndWait" suffixes, "clickAndWait", "selectAndWait", "typeAndWait" etc. - (which are only available in the JS API). - - Selenium constantly keeps track of new pages loading, and sets a "newPageLoaded" - flag when it first notices a page load. Running any other Selenium command after - turns the flag to false. Hence, if you want to wait for a page to load, you must - wait immediately after a Selenium command that caused a page-load. - - - 'timeout' is a timeout in milliseconds, after which this command will return with an error - """ - self.do_command("waitForPageToLoad", [timeout,]) - - - def wait_for_frame_to_load(self,frameAddress,timeout): - """ - Waits for a new frame to load. - - - Selenium constantly keeps track of new pages and frames loading, - and sets a "newPageLoaded" flag when it first notices a page load. - - - See waitForPageToLoad for more information. - - 'frameAddress' is FrameAddress from the server side - 'timeout' is a timeout in milliseconds, after which this command will return with an error - """ - self.do_command("waitForFrameToLoad", [frameAddress,timeout,]) - - - def get_cookie(self): - """ - Return all cookies of the current page under test. - - """ - return self.get_string("getCookie", []) - - - def get_cookie_by_name(self,name): - """ - Returns the value of the cookie with the specified name, or throws an error if the cookie is not present. - - 'name' is the name of the cookie - """ - return self.get_string("getCookieByName", [name,]) - - - def is_cookie_present(self,name): - """ - Returns true if a cookie with the specified name is present, or false otherwise. - - 'name' is the name of the cookie - """ - return self.get_boolean("isCookiePresent", [name,]) - - - def create_cookie(self,nameValuePair,optionsString): - """ - Create a new cookie whose path and domain are same with those of current page - under test, unless you specified a path for this cookie explicitly. - - 'nameValuePair' is name and value of the cookie in a format "name=value" - 'optionsString' is options for the cookie. Currently supported options include 'path', 'max_age' and 'domain'. the optionsString's format is "path=/path/, max_age=60, domain=.foo.com". The order of options are irrelevant, the unit of the value of 'max_age' is second. Note that specifying a domain that isn't a subset of the current domain will usually fail. - """ - self.do_command("createCookie", [nameValuePair,optionsString,]) - - - def delete_cookie(self,name,optionsString): - """ - Delete a named cookie with specified path and domain. Be careful; to delete a cookie, you - need to delete it using the exact same path and domain that were used to create the cookie. - If the path is wrong, or the domain is wrong, the cookie simply won't be deleted. Also - note that specifying a domain that isn't a subset of the current domain will usually fail. - - Since there's no way to discover at runtime the original path and domain of a given cookie, - we've added an option called 'recurse' to try all sub-domains of the current domain with - all paths that are a subset of the current path. Beware; this option can be slow. In - big-O notation, it operates in O(n\*m) time, where n is the number of dots in the domain - name and m is the number of slashes in the path. - - 'name' is the name of the cookie to be deleted - 'optionsString' is options for the cookie. Currently supported options include 'path', 'domain' and 'recurse.' The optionsString's format is "path=/path/, domain=.foo.com, recurse=true". The order of options are irrelevant. Note that specifying a domain that isn't a subset of the current domain will usually fail. - """ - self.do_command("deleteCookie", [name,optionsString,]) - - - def delete_all_visible_cookies(self): - """ - Calls deleteCookie with recurse=true on all cookies visible to the current page. - As noted on the documentation for deleteCookie, recurse=true can be much slower - than simply deleting the cookies using a known domain/path. - - """ - self.do_command("deleteAllVisibleCookies", []) - - - def set_browser_log_level(self,logLevel): - """ - Sets the threshold for browser-side logging messages; log messages beneath this threshold will be discarded. - Valid logLevel strings are: "debug", "info", "warn", "error" or "off". - To see the browser logs, you need to - either show the log window in GUI mode, or enable browser-side logging in Selenium RC. - - 'logLevel' is one of the following: "debug", "info", "warn", "error" or "off" - """ - self.do_command("setBrowserLogLevel", [logLevel,]) - - - def run_script(self,script): - """ - Creates a new "script" tag in the body of the current test window, and - adds the specified text into the body of the command. Scripts run in - this way can often be debugged more easily than scripts executed using - Selenium's "getEval" command. Beware that JS exceptions thrown in these script - tags aren't managed by Selenium, so you should probably wrap your script - in try/catch blocks if there is any chance that the script will throw - an exception. - - 'script' is the JavaScript snippet to run - """ - self.do_command("runScript", [script,]) - - - def add_location_strategy(self,strategyName,functionDefinition): - """ - Defines a new function for Selenium to locate elements on the page. - For example, - if you define the strategy "foo", and someone runs click("foo=blah"), we'll - run your function, passing you the string "blah", and click on the element - that your function - returns, or throw an "Element not found" error if your function returns null. - - We'll pass three arguments to your function: - - * locator: the string the user passed in - * inWindow: the currently selected window - * inDocument: the currently selected document - - - The function must return null if the element can't be found. - - 'strategyName' is the name of the strategy to define; this should use only letters [a-zA-Z] with no spaces or other punctuation. - 'functionDefinition' is a string defining the body of a function in JavaScript. For example: ``return inDocument.getElementById(locator);`` - """ - self.do_command("addLocationStrategy", [strategyName,functionDefinition,]) - - - def capture_entire_page_screenshot(self,filename,kwargs): - """ - Saves the entire contents of the current window canvas to a PNG file. - Contrast this with the captureScreenshot command, which captures the - contents of the OS viewport (i.e. whatever is currently being displayed - on the monitor), and is implemented in the RC only. Currently this only - works in Firefox when running in chrome mode, and in IE non-HTA using - the EXPERIMENTAL "Snapsie" utility. The Firefox implementation is mostly - borrowed from the Screengrab! Firefox extension. Please see - http://www.screengrab.org and http://snapsie.sourceforge.net/ for - details. - - 'filename' is the path to the file to persist the screenshot as. No filename extension will be appended by default. Directories will not be created if they do not exist, and an exception will be thrown, possibly by native code. - 'kwargs' is a kwargs string that modifies the way the screenshot is captured. Example: "background=#CCFFDD" . Currently valid options: - * background - the background CSS for the HTML document. This may be useful to set for capturing screenshots of less-than-ideal layouts, for example where absolute positioning causes the calculation of the canvas dimension to fail and a black background is exposed (possibly obscuring black text). - - - """ - self.do_command("captureEntirePageScreenshot", [filename,kwargs,]) - - - def rollup(self,rollupName,kwargs): - """ - Executes a command rollup, which is a series of commands with a unique - name, and optionally arguments that control the generation of the set of - commands. If any one of the rolled-up commands fails, the rollup is - considered to have failed. Rollups may also contain nested rollups. - - 'rollupName' is the name of the rollup command - 'kwargs' is keyword arguments string that influences how the rollup expands into commands - """ - self.do_command("rollup", [rollupName,kwargs,]) - - - def add_script(self,scriptContent,scriptTagId): - """ - Loads script content into a new script tag in the Selenium document. This - differs from the runScript command in that runScript adds the script tag - to the document of the AUT, not the Selenium document. The following - entities in the script content are replaced by the characters they - represent: - - < - > - & - - The corresponding remove command is removeScript. - - 'scriptContent' is the Javascript content of the script to add - 'scriptTagId' is (optional) the id of the new script tag. If specified, and an element with this id already exists, this operation will fail. - """ - self.do_command("addScript", [scriptContent,scriptTagId,]) - - - def remove_script(self,scriptTagId): - """ - Removes a script tag from the Selenium document identified by the given - id. Does nothing if the referenced tag doesn't exist. - - 'scriptTagId' is the id of the script element to remove. - """ - self.do_command("removeScript", [scriptTagId,]) - - - def use_xpath_library(self,libraryName): - """ - Allows choice of one of the available libraries. - - 'libraryName' is name of the desired library Only the following three can be chosen: - * "ajaxslt" - Google's library - * "javascript-xpath" - Cybozu Labs' faster library - * "default" - The default library. Currently the default library is "ajaxslt" . - - If libraryName isn't one of these three, then no change will be made. - """ - self.do_command("useXpathLibrary", [libraryName,]) - - - def set_context(self,context): - """ - Writes a message to the status bar and adds a note to the browser-side - log. - - 'context' is the message to be sent to the browser - """ - self.do_command("setContext", [context,]) - - - def attach_file(self,fieldLocator,fileLocator): - """ - Sets a file input (upload) field to the file listed in fileLocator - - 'fieldLocator' is an element locator - 'fileLocator' is a URL pointing to the specified file. Before the file can be set in the input field (fieldLocator), Selenium RC may need to transfer the file to the local machine before attaching the file in a web page form. This is common in selenium grid configurations where the RC server driving the browser is not the same machine that started the test. Supported Browsers: Firefox ("\*chrome") only. - """ - self.do_command("attachFile", [fieldLocator,fileLocator,]) - - - def capture_screenshot(self,filename): - """ - Captures a PNG screenshot to the specified file. - - 'filename' is the absolute path to the file to be written, e.g. "c:\blah\screenshot.png" - """ - self.do_command("captureScreenshot", [filename,]) - - - def capture_screenshot_to_string(self): - """ - Capture a PNG screenshot. It then returns the file as a base 64 encoded string. - - """ - return self.get_string("captureScreenshotToString", []) - - - def captureNetworkTraffic(self, type): - """ - Returns the network traffic seen by the browser, including headers, AJAX requests, status codes, and timings. When this function is called, the traffic log is cleared, so the returned content is only the traffic seen since the last call. - - 'type' is The type of data to return the network traffic as. Valid values are: json, xml, or plain. - """ - return self.get_string("captureNetworkTraffic", [type,]) - - def addCustomRequestHeader(self, key, value): - """ - Tells the Selenium server to add the specificed key and value as a custom outgoing request header. This only works if the browser is configured to use the built in Selenium proxy. - - 'key' the header name. - 'value' the header value. - """ - return self.do_command("addCustomRequestHeader", [key,value,]) - - def capture_entire_page_screenshot_to_string(self,kwargs): - """ - Downloads a screenshot of the browser current window canvas to a - based 64 encoded PNG file. The \ *entire* windows canvas is captured, - including parts rendered outside of the current view port. - - Currently this only works in Mozilla and when running in chrome mode. - - 'kwargs' is A kwargs string that modifies the way the screenshot is captured. Example: "background=#CCFFDD". This may be useful to set for capturing screenshots of less-than-ideal layouts, for example where absolute positioning causes the calculation of the canvas dimension to fail and a black background is exposed (possibly obscuring black text). - """ - return self.get_string("captureEntirePageScreenshotToString", [kwargs,]) - - - def shut_down_selenium_server(self): - """ - Kills the running Selenium Server and all browser sessions. After you run this command, you will no longer be able to send - commands to the server; you can't remotely start the server once it has been stopped. Normally - you should prefer to run the "stop" command, which terminates the current browser session, rather than - shutting down the entire server. - - """ - self.do_command("shutDownSeleniumServer", []) - - - def retrieve_last_remote_control_logs(self): - """ - Retrieve the last messages logged on a specific remote control. Useful for error reports, especially - when running multiple remote controls in a distributed environment. The maximum number of log messages - that can be retrieve is configured on remote control startup. - - """ - return self.get_string("retrieveLastRemoteControlLogs", []) - - - def key_down_native(self,keycode): - """ - Simulates a user pressing a key (without releasing it yet) by sending a native operating system keystroke. - This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing - a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and - metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular - element, focus on the element first before running this command. - - 'keycode' is an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes! - """ - self.do_command("keyDownNative", [keycode,]) - - - def key_up_native(self,keycode): - """ - Simulates a user releasing a key by sending a native operating system keystroke. - This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing - a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and - metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular - element, focus on the element first before running this command. - - 'keycode' is an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes! - """ - self.do_command("keyUpNative", [keycode,]) - - - def key_press_native(self,keycode): - """ - Simulates a user pressing and releasing a key by sending a native operating system keystroke. - This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing - a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and - metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular - element, focus on the element first before running this command. - - 'keycode' is an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes! - """ - self.do_command("keyPressNative", [keycode,]) -