ui5-community / wdi5

official UI5 end-to-end test framework for UI5 web-apps. wdi5 = Webdriver.IO + UI5 Test API
https://ui5-community.github.io/wdi5/
Apache License 2.0
102 stars 43 forks source link

No way to target the unit of measure field on UI using FormActions #641

Closed FrankVisuals closed 2 months ago

FrankVisuals commented 2 months ago

We have a field defined on our object page that has a unit of measure added using the @@Measures.Unit annotation. This results in the UI rendering two fields with the IDs

com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit-inner-inner

and

com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit-inner-unit-inner

They are not connected fields. Therefore, I cannot access the unit input field using a form action. For the quantity I can use

When.onTheModeledDatasetsObjectPage.onForm({ section: "GeneralDataCollectionFacet" }).iChangeField({ property: "referenceQuantity" }, "1");

However, I cannot find any way to target the second field that has just a different suffix.

Relevant Code:

CAP CDS (node.js)

referenceQuantity @Measures.Unit: referenceUoM;

For the object page we defined the two fields

{
  $Type: 'UI.DataField',
  Value: referenceQuantity
},
{
  $Type: 'UI.DataField',
  Value: referenceUoM
}

This leads to the following result image

HTML

<div id="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-content" data-sap-ui="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-content" data-sap-ui-render="" style="width: 100%;"><div id="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit" data-sap-ui="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit" data-sap-ui-render="" class="sapUiMdcFieldBase sapUiMdcFieldBaseMoreFields" style="width: 100%;"><div id="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit-inner" data-sap-ui="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit-inner" data-sap-ui-render="" data-ui5-accesskey="" class="sapMInputBase sapMInputBaseHeightMargin sapMInput sapUiMdcFieldInput" style="width: 70%;"><div id="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit-inner-content" class="sapMInputBaseContentWrapper" style="width: 100%;"><input id="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit-inner-inner" value="" aria-required="true" aria-describedby="__text152" aria-labelledby="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity-label" type="text" autocomplete="off" class="sapMInputBaseInner" style="text-align: right;"></div></div><div id="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit-inner-unit" data-sap-ui="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit-inner-unit" data-sap-ui-render="" data-ui5-accesskey="" class="sapMInputBase sapMInputBaseHeightMargin sapMInput sapUiMdcFieldInput sapMInputBaseHasEndIcons" style="width: 30%;"><div id="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit-inner-unit-content" class="sapMInputBaseContentWrapper" style="width: 100%;"><input id="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit-inner-unit-inner" value="" aria-required="true" aria-describedby="__text153 __text26" aria-haspopup="listbox" aria-autocomplete="both" aria-labelledby="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity-label" type="text" autocomplete="off" class="sapMInputBaseInner" style="text-align: right;"><div tabindex="-1" class="sapMInputBaseIconContainer"><span id="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit-inner-unit-vhi" data-sap-ui="com.sap.sus.c21.emissionfactors.ui::ModeledDatasetDetail--fe::FormContainer::GeneralData::FormElement::DataField::referenceQuantity::Field-edit-inner-unit-vhi" data-sap-ui-render="" role="button" aria-label="Show Value Help" data-sap-ui-icon-content="" class="sapUiIcon sapUiIconMirrorInRTL sapUiIconPointer sapMInputBaseIcon" style="font-family: SAP-icons;"></span></div></div></div></div></div>

To Reproduce Steps to reproduce the behavior:

  1. Create two fields, connect them with @Measures.Unit
  2. Display both on Object Page Facet
  3. Inspect

Expected behavior I'd expect either an option specifically for units (as it seems to be a special case), or some way of giving the suffix as input to the selector.

Runtime Env (please complete the following information):

Siolto commented 2 months ago

The FioriElementsTestLibrary is developed by SAP. wdi5 is just using it. Could you raise this issue/question to the FioriElements SAP Team?

A workaround for this case could be to just identity the field with normal wdi5 and the help of the Test Recorder:

await browser.asControl({...})
FrankVisuals commented 2 months ago

Thanks for the fast reply @Siolto, i will raise the issue there. I am aware of the workaround, but try to build the tests as much as possible using the test lib :)