Expand my Community achievements bar.

Hobbes Documentation for `hobs.WebElements`

Avatar

Level 1

Hello,

I've begun writing some Hobbes UI tests for our AEM 6.1 instances, following along with the examples at this page, and the API docs at this page. However, I noticed that there are some methods referenced in the examples that don't appear in the API docs. For instance, in the example called "CQ - Geometrixx Navigation Tests" there is this code snippet included:

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

I'm curious about the calls to `hobs.WebElements.GeoOutdoors.getMenNavHref()` and similar. It appears as if this method is dynamically looking up the href's for certain elements in the app, is this functionality that should be available for our custom apps as well? If so, is this documented anywhere?

Also, on the publicly linked source code for `hobbes.js` from the API docs, it appears that there is a function called `handleAutomatedRun()`. It sounds (and looks) like this would support automated testing that doesn't require one to first navigate to a page and manually enable Developer mode. Is this currently working, or is there a road-map for when this sort of functionality will be available?

Thanks for your time,

Gerard Van Halsema 

3 Replies

Avatar

Level 4

Hi Gerard,

In the example that you've shown above, "hobs.WebElements.GeoOutdoors" is the name of a variable that is registered under the 'hobs' global namespace. Similarly, the hobs.WebElements.GeoOutdoors.getMenNavHref() is a method which is defined in the hobbes test script (created for the specific content page in question) also registered under the hobs global namespace. It is a custom javascript function that would be created by the test author.

As for the 'handleAutomatedRun()' method, this function is called when we navigate to the content page and execute the hobbes test in the developer pane. I don't think the method is meant to execute tests 'automatically' without manual intervention. 

Avatar

Level 1

Thanks for your reply, Naveen.

Does that mean, then, that the `hobs.WebElements` object is simply a holding ground for custom variables written by the test author? 

Currently, when pulling it up in the Chrome javascript console, `hobs.WebElements` is listed as an empty object.

Avatar

Level 4

Unfortunately , the example itself doesn't provide the namespace details under which the variables are registered. We can infer that they are all registered in the global 'hobs' namespace.

If you've checked the `hobs.WebElements' namespace and they are not there then I'd assume they are registered under the `hobs.WebElements.GeoOutdoors' namespace.