How to install
- Download version 1.0.1 of the Molybdenum environment package molybdenum-env-1.0.1.jar
- Put it somewhere on your build machine or directly into the $ANT_HOME/lib directory.
- add a taskdef to your buildfile
- if jar was put into the $ANT_HOME/lib directory
<taskdef resource="org/molyb/molybdenum.properties"/>
 | Old package names before version 1.0.0
<taskdef resource="org/molybdenum/molybdenum.properties"/>
|
-
- if jar was put somewhere
<taskdef resource="org/molyb/molybdenum.properties" classpath="<path_to_molybdenum-env_jar>"/>
 | Old package names before version 1.0.0
<taskdef resource="org/molybdenum/molybdenum.properties" classpath="<path_to_molybdenum-env_jar>"/>
|
createffprofile Task
Description
Creates a Firefox profile and sets a property with the created profile dir.
If profile already exists, it simply returns the directory of the profile in a property.
The returned directory path can be used to copy files to the profile or modify files inside the profile.
Parameters
| Attribute |
Description |
Required |
| profilename |
The name of the profile to be created or found. |
Yes |
| profiledirproperty |
The name of the property used to pass back the absolute path of the created or found profile directory. Note: The property will be set only if it is not used already. |
Yes |
Examples
<createffprofile profilename="testrun-profile" profiledirproperty="molybdenum.profile.dir"/>
cleanffprofile Task
Description
Remove the profile from Firefox profile registry and delete its content.
Parameters
| Attribute |
Description |
Required |
| profilename |
The name of the profile to be deleted |
Yes |
Examples
<cleanffprofile profilename="test-run-profile"/>
processreport Task
Description
Parses a Molybdenum report and provides a summary of results.
The build will break if at least one test was failing.
Parameters
| Attribute |
Description |
Required |
| report |
The path to the Molybdenum XML report file |
Yes |
Examples
<processreport report="target/testrun.html.xml"/>
buildschedule Task
Description
This task is forming an implicit fileset.
Builds a Molybdenum schedule out of the fileset.
Test suites are referenced relative to the schedule.
Parameters
| Attribute |
Description |
Required |
| schedule |
The path of the schedule to be generated. |
Yes |
| relocateto |
A url the links, namely the rerun links should be relocated to. |
No |
| label |
A label which will appear as attribute of the of the root element in the report. |
No |
| includetags |
A comma separated list of test tags where test should be included in the schedule.
Empty or left out parameter means: include all. |
No |
| excludetags |
A comma separated list of test tags where test should be excluded from the schedule.
Empty or left out parameter means: exclude nothing. |
No |
Parameters specified as nested Elements
This task is forming an implicit fileset. Please see the ANT manual for nested parameters.
Examples
<buildschedule schedule="src/main/resources/schedule.xml">
<include name="*test.xml"/>
<exclude name="logintest.xml"/>
</buildschedule>
molybdenum Task
Description
Creates a firefox profile, executes Molybdenum and process the report afterwards.
If at least on test fails, the build breaks.
This is a composite task of the tasks above. Additionally it adds support to modify the profile.
Parameters
| Attribute |
Description |
Required |
| profilename |
The name of the profile to be created and used to start Molybdenum |
Yes |
| firefoxexec |
Path to Firefox executable |
Yes |
| testsuite |
Path or url to the testsuite to be loaded. |
No. Molybdenum will start with empty suite if not provided. |
| report |
Path to the report HTML file to be created after testrun. Only passed on to molybdenum if testsuite is provided. |
No |
| xunitreport |
Path to a directory where the xunit report files have to be created after testrun. (since 1.0.2beta4) |
No |
| argument |
Autostart argument to be passed to Molybdenum. Only passed on to molybdenum if testsuite is provided. |
No |
| dontrun |
If set to true, Molybdenum willnot start the test run automatically. The user has to press the appropriate run button in that case. Only passed on to molybdenum if testsuite is provided. |
No. Defaults to false |
| headless |
If set to true, several UI actions are disabled to speed up the testrun. Only passed on to molybdenum if testsuite is provided. |
No. Defaults to false |
| log |
Path to a log file to be written. Does not work in Windows currently. Use "additionalFirefoxParams='-console'" as a workaround. |
No. Output goes to console if no path is provided. |
| consolelogging |
If set to true, Firefox error console output will be written to console or logfile. |
No. Defaults to false |
| cloginclude |
A regexp to filter Firefox error console output, e.g. "JavaScript.*(myhost.org)" |
No. Makes sense only if consolelogging is set to true. |
| clogexclude |
A regexp to filter Firefox error console output |
No. Makes sense only if consolelogging is set to true. |
| additionalFirefoxParams |
Any additional command line parameters to pass on to firefox, e.g. "-console" |
No. |
Parameters specified as nested Elements
extension
Used to select a Firefox extension file (XPI) to be installed in the created profile. 0 to n extensions can be installed that way.
| Attribute |
Description |
Required |
| xpi |
XPI file to be installed |
Yes |
extensionlink
Used to create a link to an extracted XPI in the profile.
| Attribute |
Description |
Required |
| linktarget |
Base directory of the extracted XPI |
Yes |
fileset
Used to select files to be copied to the created profile
filterset
Used to filter copied resources.
Examples
Minimum task call to start Molybdenum provided as packed XPI.
<molybdenum profilename="ant-molybdenum-pure"
firefoxexec="/usr/bin/firefox">
<extension xpi="../../../../molybdenum-dist/target/molybdenum-0.7.0-SNAPSHOT.xpi"/>
</molybdenum>
Same for Molybdenum provided extracted in a directory.
<molybdenum profilename="ant-molybdenum-pure"
firefoxexec="/usr/bin/firefox">
<extensionlink linktarget="../../../../molybdenum-xpi/src/main/molybdenum-extension"/>
</molybdenum>
Molybdenum started from extracted directory, writing to a log file named molybdenum.log and a file user.js copied
to the profile directory.
<molybdenum profilename="ant-molybdenum-pure"
firefoxexec="/usr/bin/firefox"
log="molybdenum.log">
<extensionlink linktarget="../../../../molybdenum-xpi/src/main/molybdenum-extension"/>
<fileset dir="../../../../molybdenum-dist/src/test/resources/firefox-profiles/molybdenum-dist">
<include name="user.js"/>
</fileset>
</molybdenum>
Additionally to above, a testsuite _suite.xml will be loaded and executed immediately. A report will be written here as well.
<molybdenum profilename="ant-molybdenum-pure"
firefoxexec="/usr/bin/firefox"
log="molybdenum.log"
testsuite="suite.xml"
report="../../../target/ant-molybdenum-report.html">
<extensionlink linktarget="../../../../molybdenum-xpi/src/main/molybdenum-extension"/>
<fileset dir="../../../../molybdenum-dist/src/test/resources/firefox-profiles/molybdenum-dist">
<include name="user.js"/>
</fileset>
</molybdenum>
Now all together: Additionally, the automatic run will be disabled, UI actions are limited to speed up test excution, an autostart argument argument coming from commandline is passed and console logging is activated.
user.js will be copied to the profile with @@extension-path@@ replaced by a value provided in the filterset.
<molybdenum profilename="ant-molybdenum-pure"
firefoxexec="/usr/bin/firefox"
log="molybdenum.log"
testsuite="suite.xml"
report="../../../target/ant-molybdenum-report.html"
dontrun="true"
headless="true"
argument="argument coming from commandline"
consolelogging="true"
cloginclude="error"
clogexclude="warning">
<extensionlink linktarget="../../../../molybdenum-xpi/src/main/molybdenum-extension"/>
<fileset dir="../../../../molybdenum-dist/src/test/resources/firefox-profiles/molybdenum-dist">
<include name="user.js"/>
</fileset>
<filterset begintoken="@@" endtoken="@@">
<filter token="extension-path" value="${project.build.directory}/selenium-core/core/scripts/user-extensions.js.sample"/>
</filterset>
</molybdenum>
Passing an URI to molybdenum
Quite often, the autostart argument you will pass to molybdenum will be an URI pointing to a variable file or dataset. In this case it makes sense to validate the URI before firefox is even started:
<target name="run-moly">
...
<fail unless="url">Provide property 'url' pointing to variables,
e.g. -Durl=http://svn.mydomain/trunk/variables.xml</fail>
<condition property="url.ok">
<http url="${url}"/>
</condition>
<fail unless="url.ok">Could not load URL: ${url}, does it start with http:// or file:// and is absolute?</fail>
...
<molybdenum argument="${url}" .../>
</target>