Skip to content

Instantly share code, notes, and snippets.

@datakurre
Forked from optilude/login.txt
Created August 12, 2012 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save datakurre/3331735 to your computer and use it in GitHub Desktop.
Save datakurre/3331735 to your computer and use it in GitHub Desktop.
Using robotframework with Plone
*** Settings ***
Documentation A test suite with a single test for valid login. This test has
... a workflow that is created using keywords from the resource file.
Resource resource.txt
*** Test Cases ***
Valid Login
${username} = Get site owner name
${password} = Get site owner password
Open Browser To Login Page
Input Username ${username}
Input Password ${password}
Submit Credentials
Welcome Message is Being Shown
[Teardown] Close Browser
*** Settings ***
Documentation A resource file containing the application specific keywords
... that create our own domain specific language. This resource
... implements keywords for testing HTML version of the test
... application.
Library Selenium2Library
Library plone.app.theming.testing.Keywords
*** Variables ***
${SERVER} localhost:55001
${BROWSER} firefox
${DELAY} 0
${SITE} plone
${LOGIN URL} http://${SERVER}/${SITE}/login
${WELCOME URL} http://${SERVER}/${SITE}/front-page
*** Keywords ***
Open Browser To Login Page
Open Browser ${LOGIN URL} ${BROWSER}
Maximize Browser Window
Set Selenium Speed ${DELAY}
Page should contain element css=#login-form
Go To Login Page
Go To ${LOGIN URL}
Page should contain element css=#login-form
Input Username [Arguments] ${username}
Input Text __ac_name ${username}
Input Password [Arguments] ${password}
Input Text __ac_password ${password}
Submit Credentials
Click Button Log in
Welcome Message is Being Shown
Page should contain You are now logged in
Login Should Have Failed
Location Should Be ${LOGIN URL}
Title Should Be Error Page
#
# Step 2 - Set versions
#
[buildout]
extends = buildout.cfg
[versions]
robotsuite = 0.5.0
robotframework = 2.7.3
robotframework-selenium2library = 1.0.1
docutils = 0.8.1
# Also more recent versions should work.
#
# Step 1 - Declare dependencies (setup.py)
#
extras_require={
'test': ['plone.app.testing', 'robotsuite', 'robotframework-selenium2library'],
},
#
# Step 4 - Create a test suite using robotsuite
#
import unittest2 as unittest
from plone.testing import layered
from robotsuite import RobotTestSuite
from plone.app.theming.testing import THEMING_ACCEPTANCE_TESTING
def test_suite():
suite = unittest.TestSuite()
suite.addTests([
layered(RobotTestSuite('login.txt'),
layer=THEMING_ACCEPTANCE_TESTING),
])
return suite
#
# Step 3 - Create a layer using the selenium base fixture (testing.py)
#
from plone.app.testing import PloneSandboxLayer
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import applyProfile
from zope.configuration import xmlconfig
from plone.app.testing.layers import IntegrationTesting
from plone.app.testing.layers import FunctionalTesting
from plone.app.testing.selenium_layers import SELENIUM_FIXTURE
class Theming(PloneSandboxLayer):
defaultBases = (PLONE_FIXTURE,)
def setUpZope(self, app, configurationContext):
# load ZCML
import plone.app.theming.tests
xmlconfig.file('configure.zcml', plone.app.theming.tests, context=configurationContext)
...
def setUpPloneSite(self, portal):
# install into the Plone site
applyProfile(portal, 'plone.app.theming:default')
class Keywords(object):
"""Robot Framework keyword library"""
def get_site_owner_name(self):
import plone.app.testing
return plone.app.testing.interfaces.SITE_OWNER_NAME
def get_site_owner_password(self):
import plone.app.testing
return plone.app.testing.interfaces.SITE_OWNER_PASSWORD
THEMING_FIXTURE = Theming()
THEMING_INTEGRATION_TESTING = IntegrationTesting(bases=(THEMING_FIXTURE,), name="Theming:Integration")
THEMING_FUNCTIONAL_TESTING = FunctionalTesting(bases=(THEMING_FIXTURE,), name="Theming:Functional")
THEMING_ACCEPTANCE_TESTING = FunctionalTesting(bases=(THEMING_FIXTURE, SELENIUM_FIXTURE,), name="Theming:Acceptance")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment