Most Powerful Open Source ERP

How To Write Zelenium Tests

How To showing how to write Zelenium integration tests for user interfaces.
  • Last Update:2016-02-11
  • Version:001
  • Language:en

Zelenium tests and common utilities are stored in erp5_ui_test business templates. 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


External Links

Selenium User Extensions for ERP5

We have the following extensions.

  • assertPortalStatusMessage that checks the value of a portal status message.
  • assertFloat that basically acts as assertText, but converts both values to float before comparting them, with this 1 000.00 is equals to 1000.

Best Practices

Selecting in a list field

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.

Reindex in the middle of a test

<!-- reindex -->
  <td tal:content="string:${here/portal_url}/Zuite_waitForActivities"/>

Keep in Mind

  • Tests should not rely on previous test runs
  • Test should have setUp and tearDown scripts which can prepare and clean up environment respectively
  • Test must not contains any hard coded values like user names, organizations, etc ... Instead configuration of former can be moved to a Python script which can be used at test rendering time to dynamically generate test
  • Test should use a non manager account but a real ERP5 account so security is taken into account whenever test is run
  • Test must be created if feasible in a way so that they can be reused and plugged into a production instance, run in it without modifying production data
  • Common code can be grouped into a "library" of macros

Zelenium Hints

  • Take care when using 'open' rather than 'openAndWait'. This can cause random test failures whenever only 'open' (fire and go one test execution) is used.
  • Whenever an ERP5 object is edited always wait for activities
  • When you have to use "type" in selenium always assert if all fields and the save button is present, before use any type into one page or any selection. This will prevent the tests become stopped waiting for confirmation in dialog is some action is not possible.

Compatibility Notes

Zelenium 0.8 uses Selenium 0.6, and SVN trunk of Zelenium uses Selenium 0.8.3. And there are some incompatibilities.

  • getLocation() returns full URL instead of path.
    • We define getAbsoluteLocation() in erp5_ui_test_core. If you use assertAbsoluteLocation() or verifyAbsoluteLocation() instead of assertLocation() or verifyLocation(), the test should work on both version.
  • isEditable() raises an error if the specified element isn't an input element.
    • We can't use assertNotEditable() or verifyNotEditable() for asserting "it isn't an input field".
  • Use
    to specify a new line in type(), assertText(), verifyText() etc. instead of a real new line in HTML code.
    • There is no way to write a test with new lines that supports both version.

Related Articles