{ "info": { "author": "Infrae", "author_email": "info@infrae.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "==================\ninfrae.testbrowser\n==================\n\n`infrae.testbrowser` is test browser for WSGI applications sharing the\nsame ideas than `zope.testbrowser`_. It only has lxml and\nzope.interface as dependency.\n\nA Selenium version of the same browser is available in this package as\nwell. It share the same API than the default one, and requires\nSelenium 2 to work.\n\n.. contents::\n\nAPI\n===\n\nBrowser\n-------\n\n``infrae.testbrowser.browser.Browser``\n Test browser. You instantiate a new one by giving your WSGI\n application to test as arguments to the constructor. The\n application will be available via ``localhost``.\n\nExample::\n\n >>> browser = Browser(MyWSGIApplication)\n\nOn the browser you have the following methods:\n\n``open(url, method='GET', query=None, form=None, form_enctype='application/x-www-form-urlencoded', data=None, data_type=None)``\n Open the given `url`, with the given `method`. If query is\n provided, it will be encoded in the URL. If form is provided, it\n will be set as payload depending of `form_enctype`\n (`application/x-www-form-urlencoded` or `multipart/form-data`). An\n authentication can be provided in the URL (via\n ``user:password@localhost``). As the host part doesn't really have\n any meaning, you can directly specify a path as URL. It return the\n HTTP status code returned by the application. An alternative to `form` is\n the `data` and `data_type` parameters. The param `data` is the pre-encoded\n body of the request, and `data_type` is the the content type of the body.\n These parameters are useful for http PUT.\n\n``reload()``\n Reload the currently open URL (sending back any posting data).\n\n``login(username, password=_marker)``\n Set an basic authorization header in the request to authenticate\n yourself with the given `username` and `password`. If `password` is\n not provided, `username` is used as password.\n\n``set_request_header(key, value)``\n Add an header called `key` with the value `value` used while\n querying the application.\n Headers are set for all further queries.\n\n``get_request_header(key)``\n Get the value of an header used while querying the\n application. Return None if there is no matching header.\n\n``clear_request_headers()``\n Remove all sets headers used while querying the\n application. Authentication one included.\n\n``get_link(content)``\n Return a link selected via content.\n\n``get_form(name=None, id=None)``\n Return a form selected via its `name` or `id` attribute (at least\n one of them is required).\n\nThe following properties are helpful as well:\n\n``url``\n Currently viewed URL, without the hostname part, but with query data\n and so.\n\n``location``\n Currently viewed path. **It is recommanded** to use this in your\n test instead of ``url``. In case of Selenium testing, the URL will\n change depending of your local testing setup, meaning if your\n Selenium is not on the same computer than your test suite, the URL\n won't be localhost).\n\n``history``\n Last previously viewed URLs.\n\n``method``\n Method used to view the current page.\n\n``status``\n HTTP status for the currently viewed page.\n\n``status_code``\n HTTP status code as an integer for the currently viewed page.\n\n``content_type``\n Content type of the currently viewed page.\n\n``headers``\n Dictionary like access to response headers.\n\n``cookies``\n Dictionary like object to access existing cookies.\n\n``contents``\n Payload of the currently viewed page.\n\n``html``\n If the response was an HTML document, this contains an LXML parsed\n tree of the document.\n\n``xml``\n If the response was an XML response, this contains an LXML parsed\n tree of it.\n\n``json``\n If the response was a JSON response, this contains the loaded JSON\n object.\n\n``options``\n Access to browser options.\n\n\nBrowser cookies\n---------------\n\nYou can access the currently set cookies with the dict-like object ``cookies``\navailable on the browser::\n\n >>> browser.cookies['mycookie']\n mycookie=myvalue\n\nIn addition to default dictionary methods, this object as the following methods:\n\n``add(name, value)``\n Add a new cookie called ``name`` with the given value ``value``.\n\n``clear``\n Clear all set cookies.\n\n\nBrowser options\n---------------\n\nThe following options are attributes of the ``options`` object,\nexample::\n\n >>> browser.options.handle_errors = False\n\n``server``\n Server name to use to query the WSGI application (default to\n ``localhost``).\n\n``port``\n Port number to use to query the WSGI application (default to ``80``).\n\n``protocol``\n HTTP protocol to use to query the WSGI application (default to\n ``HTTP/1.0``).\n\n``follow_redirect``\n Boolean indicating if a redirect must be automatically\n followed. Default to True.\n\n``follow_external_redirect``\n Boolean indicating if a redirect to a url that doesn't match the\n current server and port set in options should be automatically\n followed and handled by the current WSGI application. Activating it,\n will update the options ``server`` and ``port`` to the new value\n defined by the redirect URL. Default to False.\n\n``handle_errors``\n Set the WSGI flag ``wsgi.handleErrors`` in the WSGI\n environment. Default to True.\n\n``cookie_support``\n Boolean indicating if we must support cookie. By default to ``True``.\n\n``default_wsgi_environ``\n Dictionnary that can be used to inject variable in the WSGI environment.\n\n\nInspect\n-------\n\nThe browser as an ``inspect`` attribute. You can register an Xpath\nexpression with it, and query them after on HTML pages::\n\n >>> browser.inspect.add('feedback', '//div[@class=\"feedback\"]/span')\n >>> self.assertEqual(browser.inspect.feedback, ['Everything ok'])\n\n >>> browser.inspect.add('feedback', css='div.feedback span')\n >>> self.assertEqual(browser.inspect.feedback, ['Everything ok'])\n\n\n``add(name, xpath=None, type='link', css=None, unique=False)``\n Add an expression called `name` that can be used to inspect the HTML\n content of the browser using the `xpath` expression (or the `css`\n one). `type` can be:\n\n `text`\n The result would be a list containing the text of each matched\n element.\n\n `normalized-text`\n The result would be a list containing the text where whitespaces\n have been normalized for each matched element. (not available on\n Selenium, the text is normalized by default by the browser).\n\n `link`\n The result would be a list of links.\n\n `form`\n The result would be a list of forms.\n\n `form-actions`\n The result would be the actions of a form.\n\n `form-fields`\n The result would be the fields of a form.\n\n `clickable`\n Available only on selenium, that is a list of elements, that you\n can click on it (even if they are not links).\n\n If ``unique`` is true, no more than one item matching will be\n expected. An error will be asserted if there are more items\n matching, and ``None`` will be returned if none matched.\n\nMacros\n------\n\nMacros let you add listing of action to do on the browser. An example\nwill speak by itself::\n\n >>> def create_content(browser, identifier, title):\n ... form = browser.get_form('addform')\n ... form.get_control('identifier').value = identifier\n ... form.get_control('title').value = title\n ... assert form.inspect.actions['save'].click() == 200\n\n >>> browser.macros.add('create', create_content)\n\nNow you can create content with your browser::\n\n >>> browser.macros.create('test', 'Test Content')\n >>> browser.macros.create('othertest', 'Other Test Content')\n\n\nLinks\n-----\n\nLinks have some useful attributes and methods:\n\n``click()``\n Follow this link in the browser, and return the HTTP status code\n returned by the application.\n\n``url``\n Target URL of the link.\n\n``text``\n Text of the link.\n\nAs result of an inspect, links are pretty useful:\n\n >>> browser.inspect.add('tabs', '//div[@class=\"tabs\"]/a', type=\"link\")\n >>> self.assertEqual(browser.inspect.tabs, ['View', 'Edit'])\n >>> self.assertEqual(browser.inspect.tabs['view'].click(), 200)\n\n\nForms\n-----\n\nForms have the following methods and attributes:\n\n``name``\n Name of the form.\n\n``action``\n URL where to form is posted.\n\n``method``\n Method to use to post the form.\n\n``enctype``\n Form enctype to use to post the form.\n\n``accept_charset``\n Charset to which the form data will be encoded before being posted.\n\n``controls``\n Dictionary containing all the controls of the form.\n\n``inspect``\n Inspect attribute, working like the one of the browser. By default,\n ``inspect.actions`` is registered to return all the submit-like\n controls of the form.\n\n``get_control(name)``\n Return the given form control by its name.\n\n``submit(name=None, value=None)``\n Submit the form, potentially add the control name and the given\n value to the submission. This return the HTTP status code returned\n by the application.\n\nCalling ``str(form)`` will only return the HTML code of the form.\n\nForms support all the known HTTP controls.\n\nForm controls\n~~~~~~~~~~~~~\n\nFor consistency, all form controls share the attributes:\n\n``name``\n Name of the control.\n\n``type``\n Type of control, like value of type attribute for input and tag name\n in other cases.\n\n``value``\n Value stored in the control.\n\n``multiple``\n Boolean indicating if the control store multiple value.\n\n``options``\n If the value have to be chosen in a list of possible values, those\n are the possibilities.\n\n``checkable``\n Boolean indicating if the control can be checked (i.e. is it a checkbox).\n\n``checked``\n Boolean indicating if the control is checked (and so if the value\n will be sent if the control is checkable).\n\n\nIn addition action controls (like submit buttons, button), have:\n\n``submit()``\n Submit the form with this action. This return the HTTP status code\n returned by the application.\n\n``click()``\n Alias to ``submit()``.\n\nFor file control, you have to set as value the filename (i.e path to)\nof the file you want to upload.\n\nSelenium browser\n----------------\n\n``infrae.testbrowser.browser.selenium.Browser``\n Test browser. You instantiate a new one by giving your WSGI\n application to test as arguments to the constructor.\n\n You have to use the browser as a context manager in order to start\n and stop the server that Selenium will use to access the\n application.\n\n The following environement variable are available in order to\n control the connection to the Selenium server:\n\n - ``TESTBROWSER_BROWSER`` (default to firefox)\n\n - ``TESTBROWSER_SELENIUM_PLATFORM`` (default to the local one)\n\n - ``TESTBROWSER_SELENIUM_HOST`` (default to localhost)\n\n - ``TESTBROWSER_SELENIUM_PORT`` (default to 4444)\n\n - ``TESTBROWSER_SERVER`` (default to localhost)\n\n - ``TESTBROWSER_PORT`` (default to 8000)\n\n If you set your testsuite to connect to a Selenium server that is\n not on your computer where you run your testsuite, please set the\n server and port options so that the Selenium knows how to connect\n to your application (it should be the network name of your\n computer).\n\n The API is the same than the default browser, except for:\n\n - you can't access HTTP status or headers,\n\n - you can't change hidden fields (you can only do what the user can\n do).\n\n Cookies do work however.\n\n\nSelenium Browser options\n------------------------\n\nThe following options are attributes of the options object, example::\n\n >>> browser.options.enable_javascript = False\n\nThey are on par with the possible configuration environment variables:\n\n``enable_javascript``\n Enable or disable Javascript in Selenium.\n\n``browser``\n String used to specify which browser you expect to use,\n i.e. 'firefox' or 'chrome' for instance.\n\n``selenium_host``\n Network name of the computer where the Selenium server run.\n\n``selenium_port``\n Port number where the Selenium server run.\n\n``selenium_platform``\n Operating system where the Selenium should run the wanted browsers\n (for instance set it to 'win' if you wish Selenium to pick a browser\n on Windows).\n\n``server``\n Network name of the computer where the testsuite will be\n running. This is the name that Selenium will use to access the\n tested application.\n\n``port``\n Port on which the test application will be bound so Selenium can\n access it.\n\n\nCode repository\n===============\n\nYou can find the source code of this extensions in mercurial at\nhttps://hg.infrae.com/infrae.testbrowser.\n\n.. _zope.testbrowser: http://pypi.python.org/pypi/zope.testbrowser\n\nChangelog\n=========\n\n2.0.2 (2013/05/23)\n------------------\n\n* Add ``cssselect`` as a dependency in order to work with ``lxml``\n 3.x.\n\n* Fix ``PATH_INFO`` environment variable in the simple browser that\n was not properly quoted.\n\n2.0.1 (2012/12/10)\n------------------\n\n* Add new expression ``form-fields`` and ``form-actions`` that are\n alias to actions and fields exposed by ``form``.\n\n* Improve expressions API.\n\n2.0 (2012/09/24)\n----------------\n\n* Add the option ``follow_external_redirect`` for the standard\n browser, which let you redirect to a different domain, but that\n domain is still handled by the wsgi application (this modify browser\n options to the new domain).\n\n* Add support for automatic JSON deserialization in a ``json``\n attribute for the standard browser.\n\n* Improve expressions: add a type ``form`` to create forms out of the\n result of the expression, add a flag ``unique`` that makes possible\n for an expression to return only one value, or None if the\n expression didn't match.\n\n* Improve support for arbitrary http methods by providing ``data`` and\n ``data_type`` parameters to the method ``open`` for the standard browser.\n\n* Improve cookie support (support setting and deleting cookies, and\n multiple cookies).\n\n* Improve default WSGI environ to support HTTPS variable, if the port\n is set to ``443``.\n\n* Improve Selenium browser support.\n\n2.0b1 (2011/11/07)\n------------------\n\n* Add an initial support for test with Selenium 2. The Selenium\n browser takes a wsgi application as parameter and serves it using\n Python default wsgi server, in a thread, during the testing. The API\n of the Selenuim browser the one provided by the default one, in the\n measure of the possible.\n\n* Fix various issues concerning encoding, to allow unicode strings at\n many places.\n\n* Try to send back field values in the same order they are listed in\n the HTML document. Some systems use this to work.\n\n* Fields are allowed, for most of then, to share the same name, even\n if they are not of the same type. In this case, you set a list\n instead of a value to the widget you fetched.\n\n* Allow more things to be customized, like the hostname, port,\n protocol, the default wsgi environ. Some of those settings are\n customizable from the command line (same system than for Selenium).\n\n* The browser is a now a context manager. You can register some\n actions to be executed at the end of context manager, using\n ``handlers``.\n\n* Add support for XML in the basic browser. An lxml parse tree is\n available in the ``xml`` attribute of the browser.\n\n* This now support only Python 2.6 and 2.7.\n\n1.1 (2010-02-07)\n----------------\n\n* Add support for a ``css`` option to inspection expressions.\n\n* Add an option ``id`` to ``get_form`` in order to be able to select a\n form by its id.\n\n* Add `normalized-text` as a valid expression type to expressions: it\n return the text of the matched nodes, where whitespaces are\n normalized.\n\n* Fix sending file when no file is selected.\n\n* Fix some detection issue with the *button* tag that doesn't seems to\n be handled correctly by LXML.\n\n\n1.0 (2010-10-07)\n----------------\n\n* Initial release.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://infrae.com/products/silva", "keywords": "test wsgi application functional", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "infrae.testbrowser", "package_url": "https://pypi.org/project/infrae.testbrowser/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/infrae.testbrowser/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://infrae.com/products/silva" }, "release_url": "https://pypi.org/project/infrae.testbrowser/2.0.2/", "requires_dist": null, "requires_python": null, "summary": "Sane functionnal test browser for WSGI applications", "version": "2.0.2" }, "last_serial": 945369, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "4fea28c8fa13fbf931dd62185569eb54", "sha256": "a3d8097bc5bbae1ca4628cba1316c1afd6bfcc132e5161679079e36d463762a9" }, "downloads": -1, "filename": "infrae.testbrowser-1.0.tar.gz", "has_sig": false, "md5_digest": "4fea28c8fa13fbf931dd62185569eb54", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18494, "upload_time": "2010-10-07T13:40:39", "url": "https://files.pythonhosted.org/packages/9b/23/8aafce7c96bcb235023afd3792474863bf90ad4c226a61f358a3d6a5385d/infrae.testbrowser-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "f6997e274058e39eaed20ae122567745", "sha256": "e4f154f00a4b6f74344f548ccaaa16bfba1833e4e49ca44175c08837de64200a" }, "downloads": -1, "filename": "infrae.testbrowser-1.1.tar.gz", "has_sig": false, "md5_digest": "f6997e274058e39eaed20ae122567745", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20779, "upload_time": "2011-02-07T11:58:22", "url": "https://files.pythonhosted.org/packages/43/c7/2b48f88c7a2f22b4c61c38744ec76ecc87df022851ec2a9f3804d3dcaa22/infrae.testbrowser-1.1.tar.gz" } ], "2.0": [ { "comment_text": "", "digests": { "md5": "e624dda840450d713189db1ecca60961", "sha256": "f1d1601fb932206187ac234d3e16a7eccb42d9fbed4247b6807b02f60bdc26a5" }, "downloads": -1, "filename": "infrae.testbrowser-2.0.tar.gz", "has_sig": false, "md5_digest": "e624dda840450d713189db1ecca60961", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 46975, "upload_time": "2012-09-24T09:13:20", "url": "https://files.pythonhosted.org/packages/3b/5d/33db6dc9de695db3857b4314d01533461412fae1f3f15f98a154f9904ce2/infrae.testbrowser-2.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "7e2e867d3388a9513e0193b895d01a67", "sha256": "8e1327ff30c08aa859a63202273a6696c4690e65bf5cbfe37b8d89c12e290a32" }, "downloads": -1, "filename": "infrae.testbrowser-2.0.1.tar.gz", "has_sig": false, "md5_digest": "7e2e867d3388a9513e0193b895d01a67", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49041, "upload_time": "2012-12-10T15:50:36", "url": "https://files.pythonhosted.org/packages/a0/bf/6c3ea63b115cf86404b714637bd11278e8a305686cf85d159a065e69ab77/infrae.testbrowser-2.0.1.tar.gz" } ], "2.0.2": [ { "comment_text": "", "digests": { "md5": "fb792a176e95b888cb3dbe72f9daca94", "sha256": "7ae165943f407cacca5c1bb64dc3b57f84edfff244f0db2a17ee1081da7977f2" }, "downloads": -1, "filename": "infrae.testbrowser-2.0.2.tar.gz", "has_sig": false, "md5_digest": "fb792a176e95b888cb3dbe72f9daca94", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 47888, "upload_time": "2013-05-23T09:56:36", "url": "https://files.pythonhosted.org/packages/91/26/fa923b320c82e26369b10d363378949110554498c97bd6ea28b610fa9c35/infrae.testbrowser-2.0.2.tar.gz" } ], "2.0b1": [ { "comment_text": "", "digests": { "md5": "ee1a08f2299aa9002316a2995195d1f7", "sha256": "7703422be5b0c93e35326e151744f741652826e9b8fbf4d49f8c716f4a869c61" }, "downloads": -1, "filename": "infrae.testbrowser-2.0b1.tar.gz", "has_sig": false, "md5_digest": "ee1a08f2299aa9002316a2995195d1f7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40147, "upload_time": "2011-11-07T16:44:43", "url": "https://files.pythonhosted.org/packages/e5/85/0f947ae712dde7baa595121e4508f5b8b454f066d2c802a31250253819f1/infrae.testbrowser-2.0b1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fb792a176e95b888cb3dbe72f9daca94", "sha256": "7ae165943f407cacca5c1bb64dc3b57f84edfff244f0db2a17ee1081da7977f2" }, "downloads": -1, "filename": "infrae.testbrowser-2.0.2.tar.gz", "has_sig": false, "md5_digest": "fb792a176e95b888cb3dbe72f9daca94", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 47888, "upload_time": "2013-05-23T09:56:36", "url": "https://files.pythonhosted.org/packages/91/26/fa923b320c82e26369b10d363378949110554498c97bd6ea28b610fa9c35/infrae.testbrowser-2.0.2.tar.gz" } ] }