What is the ycommerce:testId purpose on Hybris (SAP CX Commerce)

Viewed 1048

In SAP Hybris (SAP CX) we usually see OOTB the following code:

<ycommerce:testId code="paymentType_text">
   ... some code ...
</ycommerce:testId>

If we click on testID, a description comes up "Render a text id wrapper", however, It does not print anything on the dom, so, what is the purpose of using this tag?

Thank you in advance

1 Answers

It's a Hybris JSP tag. See the following files:

  • /yacceleratorstorefront/web/webroot/WEB-INF/common/tld/ycommercetags.tld
  • /yacceleratorstorefront/web/src/de/hybris/platform/yacceleratorstorefront/tags/TestIdTag.java

TestIdTag is described as:

Tag that generates a wrapping div with the specified id. The id is suffixed with an incrementing counter for the page request to ensure that it is unique. The wrapper divs can be turned on and off via a configuration property.

The test ID can be used for testing. Without IDs, it may be difficult to use testing automation tools like Selenium, which can look for HTML elements via element ID.

It's also related to this project property:

# Turn on test IDs for selenium and smoke tests (not for production)
#yacceleratorstorefront.testIds.enable=true

As reichhart commented, and as the property comment above mentioned, this should not be enabled in Production, as it may become a security issue.

Related