Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented Flask test client driver #300

Merged
merged 4 commits into from Apr 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -8,6 +8,7 @@ python:
- "3.3"
env:
- DRIVER=tests/test_djangoclient.py
- DRIVER=tests/test_flaskclient.py
- DRIVER=tests/test_webdriver_remote.py
- DRIVER=tests/test_webdriver_firefox.py
- DRIVER=tests/test_zopetestbrowser.py
Expand Down
45 changes: 45 additions & 0 deletions docs/drivers/flask.rst
@@ -0,0 +1,45 @@
.. Copyright 2014 splinter authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.

.. meta::
:description: How to use splinter with Flask.
:keywords: splinter, python, tutorial, how to install, installation, Flask

++++++++++++
Flask client
++++++++++++

.. module:: splinter.driver.flaskclient

To use the ``flask`` driver, you need to install `Flask <https://pypi.python.org/pypi/Flask>`_,
`lxml <https://pypi.python.org/pypi/lxml>`_ and `cssselect <http://pypi.python.org/pypi/cssselect>`_.
You can install all of them in one step by running:

.. highlight:: bash

::

$ pip install splinter[flask]

Using Flask client
-------------------

To use the ``flask`` driver, you'll need to pass the string ``flask`` and an app instances via the
``app`` keyword argument when you create the ``Browser`` instance:

.. highlight:: python

::

from splinter import Browser
browser = Browser('flask', app=app)

**Note:** if you don't provide any driver to ``Browser`` function, ``firefox`` will be used.

API docs
--------

.. autoclass:: FlaskClient
:members:
:inherited-members:
3 changes: 2 additions & 1 deletion setup.py
Expand Up @@ -25,6 +25,7 @@
install_requires=['selenium>=2.39.0'],
extras_require={'zope.testbrowser': ['zope.testbrowser>=4.0.4',
'lxml>=2.3.6', 'cssselect'],
'django': ['Django==1.6.1', 'lxml>=2.3.6', 'cssselect']},
'django': ['Django==1.6.1', 'lxml>=2.3.6', 'cssselect'],
'flask': ['Flask>=0.10', 'lxml>=2.3.6', 'cssselect']},
tests_require=['coverage', 'flask'],
)
7 changes: 7 additions & 0 deletions splinter/browser.py
Expand Up @@ -34,6 +34,13 @@
except ImportError:
pass

try:
import flask # noqa
from splinter.driver.flaskclient import FlaskClient
_DRIVERS['flask'] = FlaskClient
except ImportError:
pass


def Browser(driver_name='firefox', *args, **kwargs):
"""
Expand Down