You're viewing help content for version:

Automate the execution of UI tests in web browsers and provide a test result. AEM provides a framework for automating tests for your AEM UI. Using the framework, you write and run UI tests directly in a web browser. The framework provides the following tools:

  • A javascript API for creating tests.
  • A Test panel in the the touch-optimized UI for running tests.
The AEM test framework uses Hobbes.js, a testing library written in Javascript. The Hobbes.js framework was developed for testing AEM as part of the development process. The framework is now available for public use for testing your AEM applications. 

Note:

Have a look at the Hobbes.js API documentation.

Executing Tests

Viewing test suites and test cases

Open the Testing Console to see the registered test suites. The Tests panel contains a list of test suites and their test cases.

chlimage_1

To reach the Testing Console:

  1. Navigate to Tools by selecting the Adobe Experience Manager link (top left) and then the hammer icon.

    chlimage_1
  2. Tap/click Operations.

    chlimage_1
  3. Tap/click Testing. The Testing Console opens.

Running a Single Test Case

Run a single test case from a test suite. When you run a test, the page changes as the test actions are executed. The test results appear after the actions have executed.
Icons indicate test results. Checkmark icons indicate a passed test:

chlimage_1

"X" icons indicate a failed test:

chlimage_1

To run a test:

  1. In the Tests panel, click the name of the test case that you want to run.

  2. Click the Run Test Case button.

    chlimage_1
  3. Review the results of each action of the test case by clicking the name of your test in the Result panel.

    chlimage_1

Running Multiple Tests

Test cases execute sequentially in the order that they appear in the test suite. You can drill down into a test case to see the results of each action.

chlimage_1
  1. On the Tests panel, click either the Run all tests button or the Run tests button below the title of the test suite that you want to run.

    chlimage_1
  2. When the test is complete, to view the results of each action in a test case, click the title of the test case.

    chlimage_1

Example: Creating and Using a Simple Test Suite

The following procedure steps you through the creation and execution of a test suite. The test uses the Geometrixx Outdoors sample web site. If you do not have the sample installed, you can easily modify the test to use a different web page.

  1. Open CRXDE Lite in your web browser. (http://localhost:4502/crx/de)

  2. Right-click the /etc/clientlibs folder and click Create > Create Folder. Type myTests for the name and click OK.

  3. Right-click the /etc/clientlibs/myTests folder and click Create > Create Node. Use the following property values and then click OK:

    • Name: myFirstTest
    • Type: cq:ClientLibraryFolder
  4. Add the following properties to the myFirstTest node:

    Name Type Value
    categories String[] granite.testing.hobbes.tests
    dependencies String[] granite.testing.hobbes.testrunner

    Note:

    AEM Forms only

    To test adaptive forms, add the following values to the categories and dependencies. For example:

    categories: granite.testing.hobbes.tests, granite.testing.hobbes.af.commons

    dependencies: granite.testing.hobbes.testrunner, granite.testing.hobbes.af

  5. Click Save All.

  6. Right-click the myFirstTest node and click Create > Create File. Name the file js.txt and click OK.

  7. In the js.txt file, type the following text:

    #base=.
    myTestSuite.js
  8. Click Save All and then close the js.txt file.

  9. Right-click the myFirstTest node and click Create > Create File. Name the file myTestSuite.js and click OK.

  10. Copy the following code to the myTestSuite.js file then save the file:

    new hobs.TestSuite("Home Page Test Suite", {path:"/etc/clientlibs/myTests/myFirstTest/myTestSuite.js"})
    .addTestCase(new hobs.TestCase("Navigate to home page")
       .navigateTo("/content/geometrixx-outdoors/en.html"))
    .addTestCase(new hobs.TestCase("Hover Over Topnav")
                 .mouseover("li.topnav-item-1"))
    .addTestCase(new hobs.TestCase("Click Topnav Link")
                 .click("li.topnav-item-1 a"));
  11. Navigate to the Testing console to try your Test Suite.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy