Commit 60fedaef authored by Lisa Seeto's avatar Lisa Seeto

Bug 1792250: Remove the test/selenium/ directory

removed the test/selenium directory

behatnotneeded

Change-Id: I0aa8be083c4412df93457fac50e52a3ee9f1e43e
Signed-off-by: 's avatarLisa Seeto <lisaseeto@catalyst.net.nz>
parent a8cfd50e
Selenium Test Suite for Mahara
==============================
This directory contains a series of test suites for Mahara, that can be tested
using selenium [1].
The test suites are arranged into directories. Each directory has a set of tests
(html files) and a 'test_suite' file that describes the order in which those
tests should be executed. There are some common tests in 'shared', which is not
a test suite on its own. The index.html files are generated automatically by
the generate-testsuites.py script.
To quickly set up selenium core so you can run the tests, run the
install-selenium-core.sh script present in this directory. This will set up
selenium core at http://your-mahara-install-path/selenium-core/TestRunner.html.
Writing your own Test Suite
---------------------------
You can make your own test suites if you would like. Just create another
directory and start adding tests.
You have to create a test_suite file that lists what order your tests will be
run in. Just copy one from another suite directory.
Note that what your test suite does it MUST undo. For example, if you have a
test that creates a new view, then you must also have another test that
destroys it. This is so future tests being run in the full test suite can
depend on Mahara being in a certain state.
In addition, your test suite must assume the system is visited in the logged
out state. You should use the tests in `shared/` to log a user in and then log
out again at the end of your test suite.
Also make sure your test does not use any specific URLs (e.g. 'localhost' or
'mahara-test'). Instead, rely on the path to your file instead - e.g.,
/theme/default/static/images/filename.png
The 'basic-install' test will install Mahara, then insert some users that your
tests can depend on existing. Please don't create users in your tests that you
do not remove.
generate-testsuite.py
---------------------
This script searches through all of the test suites and builds an index.html
file from each test_suite file. It also builds an index.html file that
includes them all, with 'basic-install' running first. You can use this
suite on an empty, uninstalled Mahara in order to give the entire codebase a
good workout.
TODO
----
* Make a test suite that runs basic-install then runs some of the major test
suites.
* Handle file uploads.
[1] http://www.openqa.org/selenium/
#!/bin/bash -ex
# this script accepts two optional parameters
# nemo - will use firefox-selenium-template and go background
# 3.5 - will use firefox-3.5-selenium-template and stay foreground
# the default (if no parameter) is to use firefox-selenium-template
# and stay foreground
#
# we don't drop/create the db here. callers should do that.
# some features may be customised by setting environment variables, e.g.,
# PROXYHOST=192.168.200.200, PROXYPORT=3128 to use a proxy
# MAHARA_URL=http://whatever.com/whatever_else to specify the mahara
# instance to test against.
# SUITE=TestSuite.html (an absolute or relative path to the suite.html file
# to test with. TestSuite.html is the default.
XMS=64m
XMX=256m
if [ -z $MAHARA_URL ]
then
MAHARA_URL=http://localmahara.org
fi
if [ -z $SUITE ]
then
SUITE=./TestSuite.html
fi
# Use this script to start the selenium server. A JDK is required.
# only sun 1.6 JDKs have been tested with this so far.
# for now, we use a single set of configs (assumes *chrome and FF3.0
# or iceweasel equivalent).
export SINGLEWINDOW="-singleWindow"
export REUSE="-browserSessionReuse"
unset PROXYINJECTION
FF35=0
if [ $1 = '3.5' ]
then
FF35=1
fi
# NOTE: the firefox-3.5* directory keeps changing name as new versions
# are created (3.5.1, 3.5.2). Create a /usr/lib/firefox-3.5 link that
# points to the real firefox 3.5 directory on your machine. Ignore this
# if you never use FF3.5.
# TODO: this will need to change when FF3.5 becomes the default.
if [ $FF35 == 1 ]
then
export FIREFOX_PROFILE_TEMPLATE_DIR="../firefox-profiles/3.5"
CHROME="*chrome /usr/lib/firefox-3.5/firefox-3.5"
else
# we need to use this (and set localhost:4444 as proxy in the template)
# because the various correct solutions (*chrome+proxyInjection,
# pifirefox, firefox+proxyInjection) all fail in some ways (e.g., gallery
# doesn't return, possibly waiting for stats.telecom.co.nz?). With this,
# we can then use *chrome with explicit proxy injection.
export FIREFOX_PROFILE_TEMPLATE_DIR="../firefox-profiles/3.0"
CHROME="*chrome"
fi
export SELENIUM_EXTRA=" -ensureCleanSession -trustAllSSLCertificates -forcedBrowserModeRestOfLine $CHROME"
if [ ! -z $PROXYHOST ]
then
export HTTP_PROXY="-Dhttp.proxyHost=$PROXYHOST -Dhttp.proxyPort=$PROXYPORT"
else
export HTTP_PROXY=""
fi
if [ ! -z $FIREFOX_PROFILE_TEMPLATE_DIR ]
then
FFTMPL=" -firefoxProfileTemplate $FIREFOX_PROFILE_TEMPLATE_DIR "
else
FFTMPL=""
fi
export FFTMPL
cmdline="java $HTTP_PROXY -Xms$XMS -Xmx$XMX -jar ./server//selenium-server.jar -trustAllSSLCertificates $SINGLEWINDOW $FFTMPL $PROXYINJECTION $REUSE -htmlSuite *chrome $MAHARA_URL $SUITE ./results.html $SELENIUM_EXTRA"
echo $cmdline
echo "When the tests are done, run firefox ./results.html to see the test results"
$cmdline
exit 0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="" />
<title>Add Folder</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Add Folder</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td></td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Content</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Files</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>files_filebrowser_createfolder_name</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>id=fileDropzone</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>files_filebrowser_createfolder_name</td>
<td>subfolder</td>
</tr>
<tr>
<td>click</td>
<td>files_filebrowser_createfolder</td>
<td></td>
</tr>
<tr>
<td>setSpeed</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//input[contains(@name,'files_filebrowser_edit')]</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=files_filebrowser_edit_description</td>
<td>This is a subdirectory</td>
</tr>
<tr>
<td>type</td>
<td>id=files_filebrowser_edit_tags</td>
<td>folder</td>
</tr>
<tr>
<td>click</td>
<td>id=files_filebrowser_edit_artefact</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>link=folder</td>
<td>folder</td>
</tr>
<tr>
<td>setSpeed</td>
<td>500</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//a[contains(@title,'Go to subfolder')]</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>files_filebrowser_createfolder_name</td>
<td>subsubfolder</td>
</tr>
<tr>
<td>click</td>
<td>id=files_filebrowser_createfolder</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//input[contains(@name,'files_filebrowser_delete')]</td>
<td></td>
</tr>
<tr>
<td>verifyText</td>
<td>id=uploadstatuslineundefined</td>
<td>Folder subsubfolder deleted</td>
</tr>
<tr>
<td>click</td>
<td>link=Home</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
Login_Admin
Files
Logout_User
#!/usr/bin/env python
'''Generate an index.html file for each test suite from its
test_suite description file. Then create a "master" index.html
file that installs Mahara and runs every test suite'''
import os
SHARED = 'shared'
INDEX = 'index.html'
PROCEDURE = 'test_suite'
FRONT_MATTER = '''<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Mahara Test Suite</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<tbody>
<tr><td><strong>Mahara Test Suite</strong></td></tr>
'''
BACK_MATTER = ''' </tbody>
</table>
</body>
</html>'''
START = '<tr><td><a href="'
ignore = ['.', './shared', './server', './basic-install']
def generate_index(root, files):
'''Parse the test procedure file and generate a test
suite file that can be understood by Selenium.'''
content = ''
f = open(os.path.join(root, PROCEDURE), 'r')
tests = list(s.strip() for s in f.readlines())
f.close()
for test in tests:
if test.find('#', 0, 1) == 0:
continue;
if test != '':
if test + '.html' in files:
path = '.'
elif test + '.html' in os.listdir(SHARED):
path = '../%s' % SHARED
# FIXME: this assumes test suites are only 1 level deep
else:
print 'Nonexistant test [%s]' % test
continue
line = '%s<tr><td><a href="%s/%s.html">%s</a></td></tr>\n' % (' ' * 16, path, test, test)
content += line
f = open(os.path.join(root, INDEX), 'w')
f.write('%s%s%s' % (FRONT_MATTER, content, BACK_MATTER))
f.close()
return content
if __name__ == '__main__':
master_content = ''
master_content += generate_index('./basic-install', os.listdir('./basic-install')).replace('../shared', 'shared').replace('./', '%s/' % 'basic-install')
for root, dirs, files in os.walk('.', topdown=False):
if PROCEDURE in files and root not in ignore:
master_content += generate_index(root, files).replace('../shared', 'shared').replace('./', '%s/' % root)
elif root not in ignore:
print "Directory [%s] contains no test procedure file [%s]" % (root, PROCEDURE)
f = open('TestSuite.html', 'w')
f.write('%s%s%s' % (FRONT_MATTER, master_content, BACK_MATTER))
f.close()
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="" />
<title>Add New Group</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Add New Group</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td></td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Groups</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Create group</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>editgroup_name</td>
<td>Admin Test Group</td>
</tr>
<tr>
<td>verifyValue</td>
<td>id=editgroup_open</td>
<td>on</td>
</tr>
<tr>
<td>click</td>
<td>id=editgroup_open</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=editgroup_invitefriends</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=editgroup_submit</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Groups</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Create group</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>editgroup_name</td>
<td>Admin VIP Group</td>
</tr>
<tr>
<td>click</td>
<td>id=editgroup_open</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=editgroup_request</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=editgroup_submit</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Groups</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Create group</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>editgroup_name</td>
<td>Public discussion</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=editgroup_submit</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Groups</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Create group</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>editgroup_name</td>
<td>Controlled Group</td>
</tr>
<tr>
<td>click</td>
<td>id=editgroup_open</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=editgroup_controlled</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=editgroup_submit</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=My groups</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Admin VIP Group</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Controlled Group</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Admin Test Group</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Public discussion</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="" />
<title>Reset_Groups</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Reset_Groups</td></tr>
</thead><tbody>
<tr>
<td>clickAndWait</td>
<td>link=Groups</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Admin Test Group</td>
<td></td>
</tr>
<tr>
<td>selectWindow</td>
<td>null</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=span.btn-del</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>deletegroup_submit</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Controlled Group</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=span.btn-del</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>deletegroup_submit</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Admin VIP Group</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=span.btn-del</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>deletegroup_submit</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Public discussion</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=span.btn-del</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>deletegroup_submit</td>
<td></td>
</tr>
<tr>
<td>verifyTextNotPresent</td>
<td>Admin VIP Group</td>
<td></td>
</tr>
<tr>
<td>verifyTextNotPresent</td>
<td>Controlled Group</td>
<td></td>
</tr>
<tr>
<td>verifyTextNotPresent</td>
<td>Admin Test Group</td>
<td></td>
</tr>
<tr>
<td>verifyTextNotPresent</td>
<td>Public discussion</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
Login_Admin
Add_New_Group
Reset_Groups
Logout_User
#!/bin/sh
#
# Downloads and sets up selenium core for running the Mahara selenium tests
#
# Author: Nigel McNie <nigel@catalyst.net.nz>
# Copyright: (C) 2007 Catalyst IT Ltd.
set -e
pushd $(dirname $0)
# Download selenium if we don't have it
if [ ! -r selenium-core-0.8.3.zip ]; then
wget http://release.openqa.org/selenium-core/0.8.3/selenium-core-0.8.3.zip
fi
# Bail out if we already ran the script
if [ -d ../../htdocs/selenium-core ]; then
echo "You seem to have already extracted selenium-core to ../../htdocs/selenium-core."
echo "Remove it if you want to re-install"
popd
exit
fi
# Make a temporary directory for extracting selenium to
if [ -d selenium-extract-temp ]; then
rm -rf selenium-extract-temp
fi
mkdir selenium-extract-temp
unzip -q -d selenium-extract-temp selenium-core-0.8.3.zip
cp -R selenium-extract-temp/core ../../htdocs/selenium-core
# Symlink our tests to where selenium core likes them to be
ln -s ../test/selenium ../../htdocs/tests
# Remove the temporary extract directory
rm -r selenium-extract-temp
popd
Login_Admin
institution_one_create
admin_institution_one_create
user_institution_one_create
Logout_User
admin_institution_one_login
admin_institution_one_resetpassword
generic_logout
user_institution_one_login
user_institution_one_setpassword
user_institution_one_resetpassword
generic_logout
Login_Admin
user_institution_one_delete
admin_institution_one_delete
institution_one_delete
Logout_User
Login_Admin
institution_two_create
admin_institution_two_create
user_institution_two_create
Logout_User
admin_institution_two_login
admin_institution_two_setpassword
admin_institution_two_resetpassword
generic_logout
user_institution_two_login
user_institution_two_resetpassword
generic_logout
Login_Admin
user_institution_two_delete
admin_institution_two_delete
institution_two_delete
Logout_User
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="" />
<title>Layout_add</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Layout_add</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td></td>
<td></td>
</tr>
<tr>