3

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

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Jose Serna
  • 61
  • 7

1 Answers1

4

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.

geffchang
  • 3,279
  • 2
  • 32
  • 58
  • 3
    What can also be mentioned here is that you must not use test ID on production environments because it may lower security somewhat. – reichhart May 28 '20 at 09:26
  • @reichhart Thanks for adding that information on security. The comment for `yacceleratorstorefront.testIds.enable` recommends not to use it for production, although it doesn't specify why. – geffchang May 28 '20 at 12:36