Testing Your UI Using Automated Tests

You are reading the AEM 6.1 version of Testing Your UI Using Automated Tests.
This documentation is also available for the following versions:  AEM 6.3  AEM 6.2  AEM 6.0 

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. 

Adding Tests

Use the test framework javascript API for creating and adding tests.

  1. Create a client library folder to register your tests with the Framework.
  2. Create a test suite.
  3. Add test cases to the test suite.
  4. Add actions to the Test case.
Example: Creating a Simple Test Suite is a tutorial that steps you through the creation of a test suite.

Creating a Test Client Library Folder

Create a client library folder that contains your tests. Add the following properties so that the framework recognizes the folder is as a test, and to enable access to the framework API:

Name Type Value
categories String[] cq.dev.ui.tests
dependencies String[] apps.testframework.all

Creating Test Suites

A test suite is a collection of related test cases. Add a javascript file to your client library folder that creates a hobs.TestSuite object. 

new hobs.TestSuite("My Test Suite", {path:"/etc/clientlibs/myTests/myFirstTest/myTestSuite.js"});
        

Code samples are intended for illustration purposes only.

When you create the test suite, it appears in the Tests panel of pages that are opened in Developer mode by default. The first parameter of the test suite constructor is the name that appears on the panel. The second parameter is an object of options. The path option is the path to the JS file in your client library folder. The path enables you to open the script from the Tests panel.

To prevent the test suite from appearing, set the optional registerSuite option to false:

new hobs.TestSuite("My Test Suite", {
    path: "/etc/clientlibs/myTests/myFirstTest/myTestSuite.js",
    register: false}
);
        

Code samples are intended for illustration purposes only.

Adding Test Cases

A test case represents a task that a user performs using your UI. Add test cases to your test suite to test the activities that users perform. The hobs.TestCase class represents test cases. Use the addTestCase method of the hobs.TestSuite class to add the test case.

Test cases appear below the test suites in the Tests panel of pages that are opened in Developer mode.

new hobs.TestSuite("MyTestSuite", {path: "/etc/clientlibs/myTests/myFirstTest/MyTestSuite.js"})
    .addTestCase(new hobs.TestCase("myTestCase")
    )
);
        

Code samples are intended for illustration purposes only.

The addTestCase method supports chaining for adding multiple test cases. The order of the chained methods determine the order in which they appear in the Tests panel:

new hobs.TestSuite("MyTestSuite", {path: "/etc/clientlibs/myTests/myFirstTest/MyTestSuite.js"})
    .addTestCase(new hobs.TestCase("myTestCase #1"))
    .addTestCase(new hobs.TestCase("myTestCase #2"))
    .addTestCase(new hobs.TestCase("myTestCase #3"))
);
        

Code samples are intended for illustration purposes only.

The hobs.TestCase constructor takes two parameters. The first parameter is the name of the test case that appears in the Tests panel. The second optional parameter is an object of options that control execution delay and contribution to demo mode.

Adding Actions to Test Cases

Actions are methods that perform a gesture in the UI, such as clicking a button or filling an input box with a value. The methods of the hobs.actions.Asserts and hobs.actions.Core classses are actions that you can use in your tests. All actions execute synchronously.

The following example code creates a test case that performs the following actions:

  • Navigates to a specific page.
  • Verifies the page location.
  • Verifies whether two specific HTML elements belong to a specific CSS class.
new hobs.TestSuite("Product Page Tests", {path:"/apps/geometrixx-outdoors/tests/ProductPageTests.js"})
    .addTestCase(new hobs.TestCase("Navigate to product page")
        .navigateTo("/content/geometrixx-outdoors/en/men/shorts/jola-summer.html")
        .asserts.location("/content/geometrixx-outdoors/en/men/shorts/jola-summer.html", true)
        .asserts.hasCssClass("article.product[data-sku='mnapjs.1-S']", "isHidden", false)
        .asserts.hasCssClass("article.product[data-sku='mnapjs.2-S']", "isHidden")
     );
        

Code samples are intended for illustration purposes only.

Re-Using Test Cases

Create a hobs.testCase object and use it in one or more test suites. Chained test cases are useful when you use the same series of gestures in different tests. Create a test case that performs the gestures and use the test case in your various test suites.

To make the test case available to test suites, use the hobs.framework.Manager.registerChain method. The following example code creates a hobs.TestCase object named createAssetFolderTestCase and then registers it:

var createAssetFolderTestCase = new hobs.TestCase("createAssetFolder")
    .navigateTo("/assets.html")
    .click("a.cq-damadmin-admin-actions-createfolder-activator")
    .typeInput("input#foldertitle", "assetsFolder")
    .click("button#createfolder-submit")
    .asserts.exists("article[data-type='directory'][data-path='/content/dam/assetsFolder']", true, {timeout: 10000})

hobs.framework.Manager.registerChain(createAssetFolderTestCase);
        

Code samples are intended for illustration purposes only.

Use the execTestCase action within a test case of a test suite to execute the registered test case. The execTestCase action takes the object of the registered test case as a parameter. The following example code executes the createAssetFolder test case:

new hobs.TestSuite("A Uses Chained Test Case", {path:"/etc/clientlibs/myTests/myFirstTest/useChainedTestCase.js"})
   .addTestCase(new hobs.TestCase("Check newly created asset folder is empty")
      .execTestCase(createAssetFolderTestCase));
        

Code samples are intended for illustration purposes only.

See also the example below.

Note

Make sure that the javascript that creates and registers the hobs.TestCase object is executed before the execTestCase action is executed.

Configuring the Order of Execution of Chained Test Cases

Execute chained test cases before or after each test case within a test suite, or relative to the exection of a test case. Use the before or after options when you create hobs.TestSuite and hobs.TestCase objects to configure when the chained test case executes.

Option name Object type Order of execution
before hobs.TestSuite The chained test case executes before each test case in the test suite.
before hobs.TestCase The chained test case executes before this test case.
after hobs.TestSuite The chained test case executes after each test case in this test suite.
after hobs.TestCase The chained test case executes after this test case.

The following example uses the after option in a test suite and a test case.

var assertLocationChain = new hobs.TestCase("assertLocationChain")
    .asserts.location("/content/qe/hobbes-js-test-pages/index.html")

hobs.framework.Manager.registerChain(assertLocationChain);

var assertLocationChain2 = new hobs.TestCase("assertLocationChain2")
    .asserts.location("/content/qe/hobbes-js-test-pages/test-page1.html")

hobs.framework.Manager.registerChain(assertLocationChain2);

new hobs.TestSuite("TestSuite with After Method Tests", {
    path: "/etc/clientlibs/qe/hobbes-js-sample-tests/generic/SubChainTests/BeforeAfterMethodsTests.js",
    after: assertLocationChain
})

.addTestCase(new hobs.TestCase("After method at TestSuite level navigateTo Action Main Page")
    .navigateTo("/content/qe/hobbes-js-test-pages/index.html")
)

.addTestCase(new hobs.TestCase("After method at TestSuite level - .click Action - Add DOM Element")
    .navigateTo("/content/qe/hobbes-js-test-pages/index.html")
    .asserts.exists("span#addedSpan", false)
    .click("#actBtn")
    .asserts.exists("div#domManip span#addedSpan")
)

.addTestCase(new hobs.TestCase("After method at TestCase level Check Location", {
        after: assertLocationChain2
    })
    .navigateTo("/content/qe/hobbes-js-test-pages/index.html")
    .click("#navBtn", {expectNav: true})
);
        

Code samples are intended for illustration purposes only.

Using Dynamic Parameters

Use dynamic parameters to avoid hard-coding values in your test cases.  Register a dynamic parameter and configure a default value for it. Then, reference the dynamic parameter from within a test case to use the value. Dynamic parameters are useful for preventing errors when you use the same value multiple times.  

Use the hobs.framework.Manager.registerParameter method to register the parameter. To reference the parameter, use the hobs.getParam method.

hobs.framework.Manager.registerParameter(name, value)

  • name: The name of the parameter.
  • value: The default value of the parameter.
hobs.getParam.name()
  • name: The paramteter name.
The following example registers a parameter named folderName with the default value of assetsFolder:
hobs.framework.Manager.registerParameter('folderName','assetsFolder');
        

Code samples are intended for illustration purposes only.

The following example creates a test case that references the folderName parameter:

var createAssetFolderTestCase = new hobs.TestCase("createAssetFolder")
    .navigateTo("/assets.html")
    .click("a.cq-damadmin-admin-actions-createfolder-activator")
    .typeInput("input#foldertitle", hobs.getParam.folderName())
    .click("button#createfolder-submit")

hobs.framework.Manager.registerChain(createAssetFolderTestCase);
        

Code samples are intended for illustration purposes only.

Overrding Dynamic Parameter Values

Change the value of a dynamic parameter in a test suite so that the value is used for the test cases that are in the suite. Use the same parameter name with different values according to the context of the test suite. The following example code overrides the default value of the folderName dynamic parameter.

new hobs.TestSuite("DynamicParameters-TestSuite-With-Param", 
    {
        path: "/etc/clientlibs/myTests/myFirstTest/DynamicParametersExample.js",
        params: {
            folderName: "/siteA-Assets"
        }
    }
)
        

Code samples are intended for illustration purposes only.

Similary, you can override the value of a dynamic parameter in a test case:

.addTestCase(new hobs.TestCase("Set Parameter at TestCase Level", 
        {
            params: {
                folderName: "/assets.html/content/dam/siteB-Assets"
            }
        }
    )
    .navigateTo(hobs.getParam.folderName())
)
        

Code samples are intended for illustration purposes only.

See also the example below.

Contributing Test Cases to Demo Mode

Test cases do not contribute to the behavior of Demo mode by default. To highlight the actions of a test case in demo mode, set the demoMode option of the hobs.TestCase constructor to true:

new hobs.TestCase("myTestCase",{demoMode:true})
        

Code samples are intended for illustration purposes only.

Note that test cases execute in Demo mode even though they may not contribute to the Demo mode experience.

See also the example below.

Delaying Test Execution

Use the delay option of the hobs.TestCase constructor to delay the execution of a test case. The units of the delay option are milliseconds.

new hobs.TestCase("myTestCase",{delay:3000})
        

Code samples are intended for illustration purposes only.

You can also use the delay option as an Action argument to delay the execution of the action:

new hobs.TestCase("Click Topnav Link")
             .click("li.topnav-item-1 a", {delay:9000});
        

Code samples are intended for illustration purposes only.

Executing Tests

Developer mode of the touch-optimized UI provides the Tests panel for running tests and analyzing the results.

Note

The Tests panel is only accessible when authoring a page in AEM Sites. If you only want to test Assets, you have to write custom tests but still run them from Sites.

Viewing test suites and test cases

Open a page in Developer mode to see the registered test suites. The Tests panel contains a list of test suites and their test cases.

file

Icons indicate test results. Checkmark icons indicate a passed test:

file

"X" icons indicate a failed test:

file
  1. From the Sites page, navigate to and open any web page. (http://localhost:4502/sites.html/content)

  2. From the toolbar, select Developer mode.

    file
  3. On the side panel, click the Tests tab.

    file
  4. Click the test suite name to hide or show the test cases that it contains.

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.

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

  2. Click the Run Test Case button.

    file
  3. Review the results of each action of the test case.

    file

Running All Test Cases of a Test Suite

Run all test cases of a test suite. Test cases execute sequentially in the order that they appear in the test suite. The icon next to the test case indicates the overall result of the test case. You can drill down into a test case to see the results of each action.

file
  1. On the Tests panel, click the Run Test Suite button below the title of the test suite that you want to run.

    file

    The following icon indicates which test case is executing:

    file
  2. When the test is complete, to view the results of each action in a test case, click the title of the test case. To return to the test suite, click the title of the test case again. 

Running Tests in Demo Mode

Run tests in Demo mode to observe the gestures that are being performed during the test:

  • UI items are highlighted as the test uses them.
  • The test runs more slowly to provde time to observe changes that occur on the page.
You can run entire test suites or individual test cases in Demo mode. Test cases affect the appearance of the page in Demo mode only if they are configured to contribute to Demo mode.
  1. On the Tests panel, click the Demo Mode button below the title of the test suite or test case that you want to run.

    file
  2. Click the Run Test Suite or Run Test Case button.

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[] cq.dev.ui.tests
    dependencies String[] apps.testframework.all
  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
            

    Code samples are intended for illustration purposes only.

  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"));
            

    Code samples are intended for illustration purposes only.

  11. Open a page of the Geometrixx Outdoors site, such as the Equipment page. (http://localhost:4502/editor.html/content/geometrixx-outdoors/en/equipment.html)

  12. Switch to Developer mode.

    file
  13. Click the Tests tab and locate the Home Page Tests test suite that you created.

    file
  14. Click the Run Test Suite button. When the test is complete, click the test cases to see the description of each test result.

    file

UI Test Framework Examples

Several sample tests are installed with the Geometrixx Outdoors sample web site. The path of the test folder is /apps/geometrixx-outdoors/tests. The following example further illustrate how to create test suites and test cases using various actions.

Example: Demo Mode Test Case

new hobs.TestSuite("CQ - Demo mode Tests", {path:"/etc/clientlibs/qe/hobbes-js-sample-tests/cq/DemoModeTests.js", register: true})

/*
 * TestCase: test Show Quick action Card
 */
.addTestCase(new hobs.TestCase("Demo_QuickActions_Menu_on_Card", {delay: 2500, demoMode: true})
    .navigateTo("/sites.html/content")
    .mouseover('article.card-page.foundation-collection-item.stack[data-path = "/content/geometrixx-media"]')
    .demoMode.highlightElement('ul.quickaction-bar', "green")
    .mouseout('article.card-page.foundation-collection-item.stack[data-path = "/content/geometrixx-media"]')
    .demoMode.clearHighlights()
);
        

Code samples are intended for illustration purposes only.

Example: Testing Site Navigation Features

new hobs.TestSuite("CQ - Geometrixx Navigation Tests", {path: "/etc/clientlibs/qe/hobbes-js-sample-tests/cq/GeoOutdoorsNavigationTests.js", register: true})

/*
 * TestCase: testTopMenuRedirect
 */
.addTestCase(new hobs.TestCase("testTopMenuRedirect")
    .navigateTo(hobs.WebElements.GeoOutdoors.HomeEnPage.url)
    .asserts.isTrue(function(){ return hobs.window.location.href.indexOf(hobs.WebElements.GeoOutdoors.HomeEnPage.url()) != -1;})
    .navigateTo(hobs.WebElements.GeoOutdoors.getWomenNavHref)
    .asserts.isTrue(function(){ return hobs.window.location.href.indexOf(hobs.WebElements.GeoOutdoors.getWomenNavHref()) != -1;})
    .navigateTo(hobs.WebElements.GeoOutdoors.getEquipmentNavHref)
    .asserts.isTrue(function(){ return hobs.window.location.href.indexOf(hobs.WebElements.GeoOutdoors.getEquipmentNavHref()) != -1;})
    .navigateTo(hobs.WebElements.GeoOutdoors.getMenNavHref)
    .asserts.isTrue(function(){ return hobs.window.location.href.indexOf(hobs.WebElements.GeoOutdoors.getMenNavHref()) != -1;})
)

/*
 * TestCase: testTopMenuLinks
 */
.addTestCase(new hobs.TestCase("testTopMenuLinks")
    .navigateTo(hobs.WebElements.GeoOutdoors.HomeEnPage.url)
    .asserts.isTrue(function(){ return hobs.WebElements.GeoOutdoors.getMenNavHref().indexOf("/content/geometrixx-outdoors/en/men.html") > -1;})
    .asserts.isTrue(function(){ return hobs.WebElements.GeoOutdoors.getWomenNavHref().indexOf("/content/geometrixx-outdoors/en/women.html") > -1;})
    .asserts.isTrue(function(){ return hobs.WebElements.GeoOutdoors.getEquipmentNavHref().indexOf("/content/geometrixx-outdoors/en/equipment.html") > -1;})
)

/*
 * TestCase: testLogoLink
 */
.addTestCase(new hobs.TestCase("testLogoLink")
    .navigateTo(hobs.WebElements.GeoOutdoors.HomeEnPage.url)
    .asserts.isTrue(function(){ return hobs.find('.topnav nav h1 a')[0].href.indexOf("/content/geometrixx-outdoors/en.html") > -1;})
);
        

Code samples are intended for illustration purposes only.

Example: Testing Product Purchasing

new hobs.TestSuite("CQ - Geometrixx Outdoors Buy Product Tests", {path: "/etc/clientlibs/qe/hobbes-js-sample-tests/cq/GeoOutdoorsBuyProductTests.js", register: true})

/*
 * TestCase: testBuyProduct
 */
.addTestCase(new hobs.TestCase("testBuyProduct")
    .execSyncFct(function() { hobs.utils.BrowserUtils.createCookie('wcmmode', 'preview', 1); })
    .navigateTo("/content/geometrixx-outdoors/en/men.html")
    .click('a[href$="/content/geometrixx-outdoors/en/men/shirts/ashanti-nomad.html"]', {expectNav: true})
    .fillInput('[name="product-quantity"]', '5')
    .click('input[type="submit"][value="Add to Cart"]', {expectNav: true})
    .click('a[href$="/content/geometrixx-outdoors/en/user/checkout.html"]', {expectNav: true})
    .fillInput('[name="billing.firstname"]', "TestUserFirstName")
    .fillInput('[name="billing.lastname"]', "TestUserLastName")
    .fillInput('[name="billing.street1"]', "TestStreet")
    .fillInput('[name="billing.city"]', "Bucharest")
    .fillInput('[name="billing.state"]', "Bucharest")
    .fillInput('[name="billing.zip"]', "032459")
    .execSyncFct(function() { hobs.find('[name="billing.country"]').val("AT"); })
    .fillInput('[name="shipping.firstname"]', "TestUserFirstName")
    .fillInput('[name="shipping.lastname"]', "TestUserLastName")
    .fillInput('[name="shipping.street1"]', "TestStreet")
    .fillInput('[name="shipping.city"]', "Bucharest")
    .fillInput('[name="shipping.state"]', "Bucharest")
    .fillInput('[name="shipping.zip"]', "032459")
    .execSyncFct(function() { hobs.find('[name="shipping.country"]').val("AT"); })
    .click('.form_button_submit.cq-checkout', {expectNav: true})
    .fillInput('[name="payment.primary-account-number"]', "0000000000000000")
    .fillInput('[name="payment.name-on-card"]', "Card owner")
    .fillInput('[name="payment.ccv"]', "666")
    .fillInput('[name="payment.expiration-date-month"]', "12")
    .fillInput('[name="payment.expiration-date-year"]', "20")
    .click('.form_button_submit.cq-checkout', {expectNav: true})
    .asserts.isTrue(function(){ return hobs.window.location.href.indexOf("/thank-you.html") > -1;})
);

        

Code samples are intended for illustration purposes only.

Example: Testing Assets Features

new hobs.TestSuite("CQ - DAM Basic Tests", {path: "/etc/clientlibs/qe/hobbes-js-sample-tests/cq/DAMBasicTests.js", register: true})

/*
 * TestCase: test Create Folder form - Folder name equals Folder title
 */
.addTestCase(new hobs.TestCase("Add Folder form name equal title")
    .navigateTo("/assets.html")
    .click("a.cq-damadmin-admin-actions-createfolder-activator")
    .asserts.exists("form#createfolderform")
    .typeInput("input#foldertitle", "Test Title")
    .asserts.isTrue(function() { return hobs.find("input#foldername").val() == "test-title"; })
)

/*
 * TestCase: Create Folder Form - Check Submit button is disable by default
 */
.addTestCase(new hobs.TestCase("Create folder Submit button is disable by default")
    .navigateTo("/assets.html")
    .click("a.cq-damadmin-admin-actions-createfolder-activator")
    .asserts.isEnabled("button#createfolder-submit", false)
)

/*
 * TestCase: Create Folder Form - Check Submit button is enabled once form filled
 */
.addTestCase(new hobs.TestCase("Create folder Submit button is enable when folder title is filled")
    .navigateTo("/assets.html")
    .click("a.cq-damadmin-admin-actions-createfolder-activator")
    .typeInput("input#foldertitle", "Test Title")
    .asserts.isEnabled("button#createfolder-submit")
)

/*
 * TestCase: Create Folder Form - Check Submit button is enabled once form filled
 */
.addTestCase(new hobs.TestCase("Cancel Folder creation via 'Esc' press")
    .navigateTo("/assets.html")
    .click("a.cq-damadmin-admin-actions-createfolder-activator")
    .asserts.visible("form#createfolderform")
    .execSyncFct(function() { 
        var evt = hobs.utils.MiscUtils.getEvent('keydown')
        evt.which = 27;
        hobs.window.document.dispatchEvent(evt);
    })
    .asserts.visible("form#createfolderform", false)
)
        

Code samples are intended for illustration purposes only.

Example: Dynamic Parameters

/**
 * Register the parameters
**/
hobs.framework.Manager.registerParameter("navUrl", "/communities.html");

/**
 * Create a TestSuite 
 * + Setting "navUrl" parameter at TestSuite level
**/
new hobs.TestSuite("DynamicParameters - TestSuite with param", 
    {
        path: "/etc/clientlibs/qe/hobbes-js-sample-tests/generic/DynamicParametersTests/DynamicParametersTests.js",
        params: {
            navUrl: "/sites.html/content"
        }
    }
)

/**
 * Create a TestCase
 * + Setting "navUrl" parameter at TestCase level (will overwrite TestSuite parameter value)
**/

.addTestCase(new hobs.TestCase("Test Parameter Set at TestCase Level", 
        {
            params: {
                navUrl: "/assets.html/content/dam"
            }
        }
    )
    .navigateTo(hobs.getParam.navUrl())
    .asserts.location("/assets.html/content/dam")
)

/**
 * Create a TestCase
 * No parameter set, "navUrl" will get value From TestSuite
**/
.addTestCase(new hobs.TestCase("Test Parameter Set at TestSuite Level")
    .navigateTo(hobs.getParam.navUrl())
    .asserts.location("/sites.html/content")
)


/**
 * Create a TestSuite 
 * + Setting "navUrl" parameter at TestSuite level
**/
new hobs.TestSuite("DynamicParameters - TestSuite without param", 
    {
        path: "/etc/clientlibs/qe/hobbes-js-sample-tests/generic/DynamicParametersTests/DynamicParametersTests.js"
    }
)

/**
 * Create a TestCase
 * + Setting "navUrl" parameter at TestCase level (will overwrite TestSuite parameter value)
**/

.addTestCase(new hobs.TestCase("Test Parameter Set at TestCase Level", 
        {
            params: {
                navUrl: "/assets.html/content/dam"
            }
        }
    )
    .navigateTo(hobs.getParam.navUrl())
    .asserts.location("/assets.html/content/dam")
)


/**
 * Create a TestCase
 * No parameter set, "navUrl" will get value From TestSuite
**/
.addTestCase(new hobs.TestCase("Test Parameter Set at Framework Level")
    .navigateTo(hobs.getParam.navUrl())
    .asserts.location("/communities.html")
);
        

Code samples are intended for illustration purposes only.

Example: Chained Test Cases - Adding and Deleting Folders

// Define some tests variables and place them under hobs global namespace
hobs.subchainData = {};
hobs.subchainData.folderTitle = "TestTitle";
hobs.subchainData.folderId = "testtitle";

var createAssetFolderChain = new hobs.TestCase("createAssetFolderChain")
    .navigateTo("/assets.html")
    .click("a.cq-damadmin-admin-actions-createfolder-activator")
    .typeInput("input#foldertitle", hobs.subchainData.folderTitle)
    .click("button#createfolder-submit")
    .asserts.exists("article[data-type='directory'][data-path='/content/dam/" + hobs.subchainData.folderId + "']", true, {timeout: 10000})

hobs.framework.Manager.registerChain(createAssetFolderChain);

var deleteAssetFolderChain = new hobs.TestCase("deleteAssetFolderChain")
    .navigateTo("/assets.html")
    .asserts.exists("article[data-type='directory'][data-path='/content/dam/" + hobs.subchainData.folderId + "']", true, {timeout: 10000})
    .click('button.foundation-mode-change')
    .click("article[data-type='directory'][data-path='/content/dam/" + hobs.subchainData.folderId + "']")
    .click('a.cq-damadmin-admin-actions-delete-activator')
    .asserts.exists(".cq-damadmin-admin-actions-delete")
    .click(".cq-damadmin-admin-actions-delete .coral-Button--warning.coral-Button--primary")
    .asserts.exists("article[data-type='directory'][data-path='/content/dam/" + hobs.subchainData.folderId + "']", false, {timeout: 10000})
    .click('button.foundation-mode-change.is-selected')

hobs.framework.Manager.registerChain(deleteAssetFolderChain);

new hobs.TestSuite("Sub-chaining Tests", {path:"/etc/clientlibs/qe/hobbes-js-sample-tests/generic/SubChainTests/SubChainTests.js", register: true})

/*
 * TestCase: 
 *   1. Execute "Create Asset Folder" chain
 *   2. Execute some test code with the created folder
 *   3. Clean env. by deleting the folder via the execution of the "Delete Assed Folder" chain
 */
.addTestCase(new hobs.TestCase("Check newly created asset folder is empty")
    .execTestCase(createAssetFolderChain)
    .click("article[data-type='directory'][data-path='/content/dam/" + hobs.subchainData.folderId + "'] a[data-foundation-content-history-title='" + hobs.subchainData.folderTitle + "']")
    .asserts.exists("div.no-children-banner.center")
    .execTestCase(deleteAssetFolderChain)
)

/*
 * TestCase: 
 *   1. Execute "Create Asset Folder" chain
 *   2. Execute some test code with the created folder
 *   3. Navigate to tools.html
 *   4. Execute "deleteAssetFolderChain" with resetURL 0 true. This means that we will go back
 *      to the URL that was before execution of the chain (here, tools.html)
 */
.addTestCase(new hobs.TestCase("Framework Test resetURL param of execTestCase method")
    .execTestCase(createAssetFolderChain)
    .click("article[data-type='directory'][data-path='/content/dam/" + hobs.subchainData.folderId + "'] a[data-foundation-content-history-title='" + hobs.subchainData.folderTitle + "']")
    .asserts.exists("div.no-children-banner.center")
    .navigateTo("/libs/granite/operations/content/maintenance.html")
    .execTestCase(deleteAssetFolderChain, true)
    .asserts.exists(".coral-Modal.maintenance-window-actions-configure")
)

        

Code samples are intended for illustration purposes only.

​