{ "info": { "author": "Miguel \u00c1ngel Garc\u00eda", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", "Topic :: Software Development :: Libraries :: Application Frameworks", "Topic :: Software Development :: Testing", "Topic :: Software Development :: User Interfaces" ], "description": "============== =============== ========= ============\nVERSION DOWNLOADS TESTS COVERAGE\n============== =============== ========= ============\n|pip version| |pip downloads| |travis| |coveralls|\n============== =============== ========= ============\n\n\nPyBrowserTest\n=============\n\nPyBrowserTest is a (very) small framework used to create Browser tests.\n\nIt wraps all the selenium initializations in order to make easier to\nbegin with these kind of tests. It is very flexible and can be used\nwith your favourite runner.\n\nPyBrowserTest opens a clean environment for each test. It is slow, but\nsafe.\n\nIt requires python-selenium to work properly, since it is only a\nwrapper for it.\n\nInstallation\n============\n\nJust::\n\n pip install pybrowsertest\n\n\nAn example\n==========\n\nLets start with a full example:\n\n.. code:: python\n\n import unittest\n from pybrowsertest import BrowserTestCase\n\n class AutomationTest(BrowserTestCase):\n def test_the_title_is_set(self):\n page = self.browser.open('/')\n self.assertEquals(\"Directory listing for /\", page.title)\n\n\nThis little code opens a browser, locates the page at '/' and checks\nif the title is the given one.\n\nNotice that the test class is inheriting from :code:`BrowserTestCase`, and\nhow it has a public attribute in order to get a selenium driver\ninstance. It uses this driver to load a page and make the checks.\n\n\nFeatures\n========\n\nWhat makes this small framework so special?\n\n- If one of your tests fails, **it will make a screenshot** from the last screen as additional data for debugging.\n- You can set a timeout for any element to appear.\n- It do not overwrite the methods :code:`setUp` or :code:`tearDown`, so it is safe for your current tests.\n- It uses a new browser instance for each test. This is slow, but is the safer way to ensure you have a clean environment (no cookies, sessions or whatever).\n- It reads the configuration from a file, what allows you to modify the file and run the tests again with another browser. You can change the configuration file or even set the configuration from your tests.\n- It provides some useful decorators to avoid tests in some browsers.\n- You can use your favourite runner: `unittest.main`_, `nosetests`_, `zope.testrunner`_, `pytong`_),... or even your own runner (`just like I had to do to test it`)\n\nDecorators\n----------\n\nNot all the browsers work in the same way, so there will be some tests\nthat cannot be executed in some of them. Because of that, this\nframework provides some decorators to make the developer's life\neasier:\n\n\n:code:`onlyIfBrowserIn`\n///////////////////////\n\n\nThis decorator will allow you to exclude the test only for some browsers.\n\nExample:\n\n.. code:: python\n\n @onlyIfBrowserIn('chrome', 'firefox')\n def test_example(self):\n pass\n\n:code:`onlyIfBrowserNotIn`\n//////////////////////////\n\n\nThe opposite to :code:`onlyIfBrowserIn`, only will execute the test if you\nare using these browsers.\n\n.. code:: python\n\n @onlyIfBrowserNotIn('chrome', 'firefox')\n def test_example(self):\n pass\n\n\n\nConfiguration\n-------------\n\nPyBrowserTest is highly configurable. You can use three files to\nconfigure it. From the lowest priority to the highest:\n\n- ``/etc/pybrowsertest.cfg``\n- ``.pybrowsertest.cfg``\n- ``pybrowsertest.cfg``\n\nFiles will have the tipical INI files format, with sections and keywords.\n\nPlease, check the file `browsertest.cfg.template`_ for more information.\n\nMaybe you are not interested in using your own configuration file for one testing file. You can do that by setting the variable:\n\n.. code:: python\n\n from pybrowsertest import BrowserConfiguration\n BrowserConfiguration.default_configuration_files = ['whatever']\n\nYou can override every variable by hand in your tests:\n\n.. code:: python\n\n from pybrowsertest import BrowserConfiguration\n BrowserConfiguration.default_selenium_url = 'http://localhost:6666/wd/hub'\n BrowserConfiguration.default_selenium_mode = 'firefox'\n\n\nThe API\n-------\n\nObjects have been made as simple and expected as possible. So, you can access the browser directly from your tests by calling the attribute :code:`browser`. Here you will find some methods very useful:\n\n:code:`browser`\n///////////////\n\n- :code:`open(url)`: will load a new page. It will return a \"page\" object.\n- :code:`close()`: will finish the session and close the browser. Do not use it. It will be called automatically after each test.\n- :code:`refresh()`: will refresh current page.\n- :code:`back()`: go to the previous page in history, if possible.\n- :code:`forward()`: go to the next page in history, if possible.\n- :code:`add_cookie(key,value)`: add a cookie, with its :code:`key` and :code:`value`.\n- :code:`get_cookie(key)`: retrieve a cookie by its :code:`key`.\n- :code:`delete_cookie(key)`: remove a cookie, giving its :code:`key`.\n- :code:`delete_all_cookies()`: clear all cookies.\n\n:code:`page`\n////////////\n\n- :code:`get_screenshot_as_file(filename)`: stores a PNG screenshot in the file :code:`filename`.\n- :code:`find_element(id)`: retrieve the element with the id \":code:`id`\". It should be only one.\n- :code:`find_element_by_css_selector(selector)`: retrieve the first element that matches the :code:`selector`.\n- :code:`find_elements_by_css_selector(selector)`: retrieve all the elements that match the :code:`selector`.\n- :code:`find_element_by_xpath(selector)`: retrieve the first element that matches the :code:`selector`.\n- :code:`find_elements_by_xpath(selector)`: retrieve all the elements that match the :code:`selector`.\n- :code:`find_element_by_tag_name(name)`: retrieve the first element with tag :code:`name`.\n- :code:`find_elements_by_tag_name(name)`: retrieve all the elements with tag :code:`name`.\n- :code:`find_element_by_class_name(name)`: retrieve the first element that has the class :code:`name`.\n- :code:`find_elements_by_class_name(name)`: retrieve all the elements that has the class :code:`name`.\n\nTo improve performance, all :code:`find_*` methods will return a generator. And all of them have a optional parameter :code:`timeout` that will wait some some time for the element to appear.\n\n\n:code:`widgets`\n///////////////\n\nThere are a generic Widget type, but for some types, the most used attributes can be retrieved as the object attributes and the most used actions are objects methods.\n\nAll of them will have these methods, in addition to all the :code:`find_*` ones:\n\n- :code:`click()`: simulate a mouse click on the widget.\n- :code:`get_attribute(name)`: retrieve the value of the attribute *name*.\n- :code:`is_displayed()`: True if the widget is shown.\n- :code:`is_enabled()`: True if the widget is enabled.\n\nAnd the attributes:\n\n- :code:`id`: widget identifier\n- :code:`text`: text inside the widget\n- :code:`size`: A dict like: ``{'width': 30, 'height': 30}`` with the widget size.\n- :code:`location`: the location of the object.\n- :code:`tag_name`: the widget tag.\n\n:code:`A` Widget\n________________\n\nThe widget :code:`A` will have some extra properties:\n\n- :code:`href`: target url\n- :code:`target`: url behavior.\n\n:code:`Input` Widget\n_____________________\n\nThe widget \"input\" will have some extra methods:\n\n- :code:`clear()`: removes any value\n- :code:`is_selected()`: True if the type is 'checkbox' or 'radio' and it is selected.\n- :code:`send_keys(keys)`: will type the keys one after another.\n\nand properties:\n\n- :code:`type`: the type of input\n- :code:`value`: current value\n- :code:`placeholder`: text to show when no value.\n\n\n:code:`TextArea` Widget\n_______________________\n\nThe widget \"textarea\" will have some extra methods:\n\n- :code:`clear()`: removes any value\n- :code:`send_keys(keys)`: will type the keys one after another.\n\nand properties:\n\n- :code:`rows`: number of rows\n- :code:`value`: current value\n- :code:`placeholder`: text to show when no value.\n\n:code:`Form` Widget\n___________________\n\nThe widget \"form\" will have some extra methods:\n\n- :code:`submit()`: send the form.\n\nand properties:\n\n- :code:`method`: POST or GET, usually.\n- :code:`action`: target url.\n\n\n\nContributing\n------------\n\nIf you want to contribute, you should know how to run the tests. These are the steps after cloning the repository::\n\n # You will need a Server running. You can use your own... or this:\n make tests_server\n\n # webdriver is required too:\n make selenium_server_start\n\n # This command will download all what you need for you:\n make tests\n\nBe careful: That command will let you to stop the selenium server and the local server.\n\nIf you want to see a cleaner window, just start the selenium server and the local server in different windows or redirect its output to ``/dev/null``.\n\n\nOur own runner\n//////////////\n\nIn order to test this framework, it has been necessary to build our own runner. It was necessary to catch the skipped tests, to check if they were really skipped; to catch the failed tests, to check if they were really failing, and so on. So you need to run the ``./run_tests.py`` script in order to test the own pybrowsertest library.\n\nRemember: the ``./run_tests.py`` script is not useful for your own tests; only in this library.\n\n\n.. |travis| image:: https://travis-ci.org/magmax/pybrowsertest.png\n :target: `Travis`_\n :alt: Travis results\n\n.. |coveralls| image:: https://coveralls.io/repos/magmax/pybrowsertest/badge.png\n :target: `Coveralls`_\n :alt: Coveralls results_\n\n.. |pip version| image:: https://pypip.in/v/pybrowsertest/badge.png\n :target: https://pypi.python.org/pypi/pybrowsertest\n :alt: Latest PyPI version\n\n.. |pip downloads| image:: https://pypip.in/d/pybrowsertest/badge.png\n :target: https://pypi.python.org/pypi/pybrowsertest\n :alt: Number of PyPI downloads\n\n\n.. _Travis: https://travis-ci.org/magmax/pybrowsertest\n.. _Coveralls: https://coveralls.io/r/magmax/pybrowsertest\n.. _unittest.main: http://docs.python.org/2/library/unittest.html#basic-example\n.. _nosetests: https://nose.readthedocs.org/en/latest/\n.. _zope.testrunner: https://pypi.python.org/pypi/zope.testrunner\n.. _pytong: https://code.google.com/p/pytong/\n.. _just like I had to do to test it: https://github.com/magmax/pybrowsertest/blob/master/run_tests.py\n.. _browsertest.cfg.template: https://github.com/magmax/pybrowsertest/blob/master/browsertest.cfg.template", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/magmax/pybrowsertest", "keywords": null, "license": "LGPL", "maintainer": null, "maintainer_email": null, "name": "pybrowsertest", "package_url": "https://pypi.org/project/pybrowsertest/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pybrowsertest/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/magmax/pybrowsertest" }, "release_url": "https://pypi.org/project/pybrowsertest/0.0.5/", "requires_dist": null, "requires_python": null, "summary": "Facility to use Selenium", "version": "0.0.5" }, "last_serial": 1093040, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "0d02f7d4ab269867bbea598542f5f8d9", "sha256": "7c3aab288208c4d8066a40c1a582d1833dcf5ce486c94b915179c2ab3c86f49c" }, "downloads": -1, "filename": "pybrowsertest-0.0.2.tar.gz", "has_sig": false, "md5_digest": "0d02f7d4ab269867bbea598542f5f8d9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8110, "upload_time": "2014-05-15T06:46:33", "url": "https://files.pythonhosted.org/packages/3f/97/82a8db18835713d4a75eefe5b9f223459f48ffe35be3b9654829fe6d1dd7/pybrowsertest-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "2a5ac2cf6b485275050bb8d4e641501c", "sha256": "fbeeff3950a72b017611f39c76dfce90e5149157129aaaa919bbcbe4a8458614" }, "downloads": -1, "filename": "pybrowsertest-0.0.3.tar.gz", "has_sig": false, "md5_digest": "2a5ac2cf6b485275050bb8d4e641501c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9347, "upload_time": "2014-05-15T07:46:42", "url": "https://files.pythonhosted.org/packages/f0/13/d6e0a33001883f4774b293ce1c5e4d71963e614cc836d31b1d791af5a504/pybrowsertest-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "f3659bad5f80ef64cc802a4aadfe48e0", "sha256": "7513da7ff16595dbd7cd9b00f1482c401cbdc8e3d518cdb27641f6bb93d34bc9" }, "downloads": -1, "filename": "pybrowsertest-0.0.4.tar.gz", "has_sig": false, "md5_digest": "f3659bad5f80ef64cc802a4aadfe48e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9388, "upload_time": "2014-05-15T07:52:00", "url": "https://files.pythonhosted.org/packages/bb/36/14fe56ba0e40585c3293c0347ba44cf7f325a772fd8c9495fa5638e2b3fb/pybrowsertest-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "820d3db69e7f4b7e5ee49d849de55a85", "sha256": "b755fdbb5cf849505db07046fdf0b0b9668152e8e0c7a7c70f9fe79fef887599" }, "downloads": -1, "filename": "pybrowsertest-0.0.5.tar.gz", "has_sig": false, "md5_digest": "820d3db69e7f4b7e5ee49d849de55a85", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9392, "upload_time": "2014-05-15T07:54:42", "url": "https://files.pythonhosted.org/packages/1e/11/fd8d7382eaae2ee744eec741ea08941679ba5aac14ddd9a162d7e6e2febb/pybrowsertest-0.0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "820d3db69e7f4b7e5ee49d849de55a85", "sha256": "b755fdbb5cf849505db07046fdf0b0b9668152e8e0c7a7c70f9fe79fef887599" }, "downloads": -1, "filename": "pybrowsertest-0.0.5.tar.gz", "has_sig": false, "md5_digest": "820d3db69e7f4b7e5ee49d849de55a85", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9392, "upload_time": "2014-05-15T07:54:42", "url": "https://files.pythonhosted.org/packages/1e/11/fd8d7382eaae2ee744eec741ea08941679ba5aac14ddd9a162d7e6e2febb/pybrowsertest-0.0.5.tar.gz" } ] }