Zelenium tests and common utilities are stored in erp5_ui_test business templates. Many other tests could also be found in erp5_*_ui_test. Zuites are stored in portal_tests and are organized in Zuite recursively. A zuite is an set of tests stored as Page Templates (see also HowToRunZeleniumTests).
Table of Contents
Zelenium, how the name hints, is Selenium test tool built into Zope itself. It is accessible at <instance>/erp5/portal_tests/manage_main. Make sure that you have business template erp5_ui_test installed.
To create a test, you need to create a Zuite first using drop-down menu on top-right corner. Zuite is a kind of folder and contains all runnable tests. As the ID, use "<module>_ui_zuite", for example "renderjs_ui_listbox_zuite". Then navigate inside your new Zuite and create a Page Template with ID starting at "test" such as "testMyModuleFormSubmit".
Below is an example of test code that you could save as a Page Template :
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test My Module UI</title>
<table cellpadding="1" cellspacing="1" border="1">
<tr><td rowspan="1" colspan="3">My Module Zuite</td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<td>//a[@data-i18n="Submit" and @type="submit"]</td>
Selector could be xPath expression (in form of "//expression") or simplified selector.
Text (or regexp) can be either glob or regular expression form.
Assert versus Verify is subtle but important. Verify continues the test if the condition fails. They are completely interchangeable in the way that every assert* has its verify* alias.
We have the following extensions.
When you waitForElement it might never show up because it is hidden in the smallest screens. Even though the tests are running at 1280x1024x24 it is better to optimize your tests for 1024x768 to be super-sure I think.
When using command type for input[@type="date"] the value must be in form YYYY-MM-DD. Keep in mind the leading 0 to make single-digit numbers follow DD or MM pattern.
When using selectAndWait command and the element is already selected, selenium hangs. The solution is to use assertSelected before using selectAndWait, so if the selection is not what you expect it to be, selectAndWait will not be executed.
You should avoid doing useless reindex in the middle of tests. Every time you use it, this means the scenario you are checking would surely not work without reindex. It is usually better when user can do many actions without the need to wait for indexation. Though, indexing is still useful in various cases, like checking catalog search. In such case you could do as follow :
<!-- reindex -->
Zelenium 0.8 uses Selenium 0.6, and SVN trunk of Zelenium uses Selenium 0.8.3. And there are some incompatibilities.