Skip to main content

A robot framework library for Django.

Project description

https://travis-ci.org/kitconcept/robotframework-djangolibrary.svg?branch=master

Introduction

DjangoLibrary is a web testing library to test Django with Robot Framework. It uses Selenium2Library to run tests against a real browser instance.

The library will automatically start and stop your Django instance while running the tests. It also comes with serveral autologin keywords that allow you to login different users during your tests, without the need to actually access the login page.

Documentation

Robot Framework Django Library Keyword Documentation

Installation

$ pip install robotframework-djangolibrary

In order to be able to use DjangoLibrary’s autologin keywords you have to add the AutologinAuthenticationMiddleware to your MIDDLEWARE_CLASSES in your settings.py:

MIDDLEWARE_CLASSES = (
    ...
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'DjangoLibrary.middleware.AutologinAuthenticationMiddleware',
)

First Robot Test

In order to write your first robot test, make sure that you include Selenium2Library and DjangoLibrary. Create a test.robot file with the following content:

*** Variables ***

${SERVER}               http://localhost:8000/
${BROWSER}              firefox


*** Settings ***

Documentation   Django Robot Tests
Library         Selenium2Library  timeout=10  implicit_wait=0.5
Library         DjangoLibrary  127.0.0.1  8080
Suite Setup     Open Browser To Login Page
Suite Teardown  Close Browser


*** Keywords ***

Open Browser To Login Page
  Open Browser  ${SERVER}  ${BROWSER}
  Maximize Browser Window


*** Test Cases ***

Scenario: As a visitor I can visit the django default page
  Go To  ${SERVER}
  Wait until page contains element  id=explanation
  Page Should Contain  It worked!
  Page Should Contain  Congratulations on your first Django-powered page.

Run Tests

Then you can run the test with pybot:

$ pybot test.robot

The output should look like this:

==============================================================================
Test :: Django Robot Tests
==============================================================================
Scenario: As a visitor I can visit the django default page            | PASS |
------------------------------------------------------------------------------
Test :: Django Robot Tests                                            | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output:  /home/timo/workspace/prounix/robotframework-djangolibrary/output.xml
Log:     /home/timo/workspace/prounix/robotframework-djangolibrary/log.html
Report:  /home/timo/workspace/prounix/robotframework-djangolibrary/report.html

Development

Checkout repository from github:

$ git clone https://github.com/kitconcept/robotframework-djangolibrary.git

Create a virtual Python environment:

$ cd robotframework-djangolibrary/
$ virtualenv .env
$ source .env/bin/activate

Install robotframework-djangolibrary in development mode:

$ python setup.py develop

Install the requirements:

$ pip install -r requirements.txt

Run robotframework-djangolibrary tests:

$ pybot DjangoLibrary/tests/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework-djangolibrary-1.0a2.tar.gz (51.1 kB view details)

Uploaded Source

File details

Details for the file robotframework-djangolibrary-1.0a2.tar.gz.

File metadata

File hashes

Hashes for robotframework-djangolibrary-1.0a2.tar.gz
Algorithm Hash digest
SHA256 3d9e84d6a2c153a4dc44ec30c18e4547d7e66a5d5edfdbe3b6bc6293a9cae78b
MD5 883d85a97e3d73d9725dac38eaea1611
BLAKE2b-256 29c026df1e4bc03850961603315687d1d8971435e18c8dcd04098911a4901e34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page