Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can´t get control with ancestor selector in UI5 version 1.71 #491

Open
marianfoo opened this issue Jun 21, 2023 · 15 comments
Open

Can´t get control with ancestor selector in UI5 version 1.71 #491

marianfoo opened this issue Jun 21, 2023 · 15 comments
Assignees
Labels
bug Something isn't working stale

Comments

@marianfoo
Copy link
Member

marianfoo commented Jun 21, 2023

Describe the bug

I try to get sap.m.OverflowToolbar with ancestor selector.

XML View

  <exceldialog:ExcelDialog contentWidth="{= ${device>/system/phone} ? '100%' : '40vw' }" contentHeight="150px" verticalScrolling="false">
    <exceldialog:customHeader >
      <OverflowToolbar>
        <Title text="{i18n>excelupload}" />
        <ToolbarSpacer/>
        <Button press="showPreview" text="{i18n>showPreview}" icon="sap-icon://display" visible="{= !${info>/hidePreview}}"/>
        <Button press="onTempDownload" text="{i18n>downloadTemplate}" icon="sap-icon://download-from-cloud" />
        <Button press="onOpenOptionsDialog" text="{i18n>showOptionMenu}" visible="{= ${info>/showOptions}}">
          <layoutData>
            <OverflowToolbarLayoutData priority="AlwaysOverflow"/>
          </layoutData>
        </Button>
      </OverflowToolbar>
    </exceldialog:customHeader>
    <exceldialog:content>
      <FlexBox direction="Column" height="100%" width="80%" alignItems="Stretch" justifyContent="Center" fitContainer="true" class="centered">
        <MessageStrip xmlns:core="sap.ui.core" core:require="{ formatMessage: 'sap/base/strings/formatMessage' }" visible="{= ${info>/dataRows} > 0}" text="{
        parts: [
          'i18n>dataRows',
          'info>/dataRows'
        ],
        formatter: 'formatMessage'
      }" type="Success" enableFormattedText="true" showIcon="true">
          <layoutData>
            <FlexItemData growFactor="1" styleClass="centeredFlex" />
          </layoutData>
        </MessageStrip>
        <upload:FileUploader placeholder="{i18n>exceluploadPlaceholder}" fileType="xlsx,xls,csv" change="onFileUpload" sameFilenameAllowed="true" width="100%">
          <upload:layoutData>
            <FlexItemData growFactor="5" styleClass="centeredFlex"/>
          </upload:layoutData>
        </upload:FileUploader>
      </FlexBox>
    </exceldialog:content>
    <exceldialog:buttons>
      <Button text="{i18n>upload}" press="onUploadSet" type="Emphasized" enabled="{= ${info>/dataRows} > 0}" />
      <Button press="onCloseDialog" text="{i18n>close}" />
    </exceldialog:buttons>
  </exceldialog:ExcelDialog>

UI5 Inspector

image

Test

https://github.com/marianfoo/ui5-cc-excelUpload/blob/4f31a5fb93a2222cb0b07decc2ba16704610319a/examples/test/specs/all/SetAvailableOptionsListReport.test.js#L61-L69

		const overflowToolbar = await browser.asControl({
			forceSelect: true,
			selector: {
				ancestor: {
					controlType: "cc.excelUpload.v0_19_0.ExcelDialog"
				},
				controlType: "sap.m.OverflowToolbar"
			}
		});

Error

image

To Reproduce

Steps to reproduce the behavior:

  1. Setup
git clone https://github.com/marianfoo/ui5-cc-excelUpload
git checkout test/wdi5-ancestor
pnpm i
npm run copyTestApps
npm run build
  1. Start App
npm run start:server
pnpm --filter ordersv2fe71 start
  1. Run Test
pnpm --filter  ui5-cc-excelupload-sample  test -- ordersv2fe 71 --spec SetAvailableOptionsListReport.test

Expected behavior
Get the overflow toolbar.

Logs/Console Output

 pnpm --filter  ui5-cc-excelupload-sample  test -- ordersv2fe 71 --spec SetAvailableOptionsListReport.test
Debugger attached.

> ui5-cc-excelupload-sample@0.0.0 test /Users/marianzeis/DEV/ui5-cc-excelUpload/examples
> wdio run ./test/wdio-base.conf.js "ordersv2fe" "71" "--spec" "SetAvailableOptionsListReport.test"

Debugger attached.

Execution of 1 spec files started at 2023-06-21T17:56:43.489Z

[0-0] RUNNING in chrome - /test/specs/all/SetAvailableOptionsListReport.test.js
[0-0] [wdi5] call of _getControl() failed because of: Error: No DOM element found using the control selector {"matchers":[null],"sOriginalControlType":"sap.m.OverflowToolbar"}
[0-0] [wdi5] error retrieving control: sapm.OverflowToolbar{"controlType":"cc.excelUpload.v0_19_0.ExcelDialog"}
[0-0] TypeError in "Upload File List Report Open Options Menu"
TypeError: overflowToolbar.getId is not a function
    at Context.<anonymous> (/Users/marianzeis/DEV/ui5-cc-excelUpload/examples/test/specs/all/SetAvailableOptionsListReport.test.js:70:51)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context.executeAsync (/Users/marianzeis/DEV/ui5-cc-excelUpload/node_modules/.pnpm/@wdio+utils@7.0.0/node_modules/@wdio/utils/build/shim.js:137:16)
    at async Context.exports.testFrameworkFnWrapper (/Users/marianzeis/DEV/ui5-cc-excelUpload/node_modules/.pnpm/@wdio+utils@7.0.0/node_modules/@wdio/utils/build/test-framework/testFnWrapper.js:51:18)
[0-0] [wdi5] call of _getControl() failed because of: Error: No DOM element found using the control selector {"matchers":[null],"sOriginalControlType":"sap.ui.layout.Grid"}
[0-0] [wdi5] error retrieving control: sapui.layout.Grid{"id":"__form0"}
[0-0] TypeError in "Upload File List Report Check only strict available"
TypeError: grid.getContent is not a function
    at Context.<anonymous> (/Users/marianzeis/DEV/ui5-cc-excelUpload/examples/test/specs/all/SetAvailableOptionsListReport.test.js:94:30)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context.executeAsync (/Users/marianzeis/DEV/ui5-cc-excelUpload/node_modules/.pnpm/@wdio+utils@7.0.0/node_modules/@wdio/utils/build/shim.js:137:16)
    at async Context.exports.testFrameworkFnWrapper (/Users/marianzeis/DEV/ui5-cc-excelUpload/node_modules/.pnpm/@wdio+utils@7.0.0/node_modules/@wdio/utils/build/test-framework/testFnWrapper.js:51:18)
[0-0] FAILED in chrome - /test/specs/all/SetAvailableOptionsListReport.test.js

 "spec" Reporter:
------------------------------------------------------------------
[chrome 114.0.5735.133 mac os x #0-0] Spec: /Users/marianzeis/DEV/ui5-cc-excelUpload/examples/test/specs/all/SetAvailableOptionsListReport.test.js
[chrome 114.0.5735.133 mac os x #0-0] Running: chrome (v114.0.5735.133) on mac os x
[chrome 114.0.5735.133 mac os x #0-0] Session ID: 20aca72763de97d47c0fb01cac35826b
[chrome 114.0.5735.133 mac os x #0-0]
[chrome 114.0.5735.133 mac os x #0-0] Upload File List Report
[chrome 114.0.5735.133 mac os x #0-0]    ✓ should trigger search on ListReport page
[chrome 114.0.5735.133 mac os x #0-0]    ✓ Open ExcelUpload Dialog
[chrome 114.0.5735.133 mac os x #0-0]    ✖ Open Options Menu
[chrome 114.0.5735.133 mac os x #0-0]    ✖ Check only strict available
[chrome 114.0.5735.133 mac os x #0-0]
[chrome 114.0.5735.133 mac os x #0-0] 2 passing (3.7s)
[chrome 114.0.5735.133 mac os x #0-0] 2 failing
[chrome 114.0.5735.133 mac os x #0-0]
[chrome 114.0.5735.133 mac os x #0-0] 1) Upload File List Report Open Options Menu
[chrome 114.0.5735.133 mac os x #0-0] overflowToolbar.getId is not a function
[chrome 114.0.5735.133 mac os x #0-0] TypeError: overflowToolbar.getId is not a function
[chrome 114.0.5735.133 mac os x #0-0]     at Context.<anonymous> (/Users/marianzeis/DEV/ui5-cc-excelUpload/examples/test/specs/all/SetAvailableOptionsListReport.test.js:70:51)
[chrome 114.0.5735.133 mac os x #0-0]     at processTicksAndRejections (node:internal/process/task_queues:95:5)
[chrome 114.0.5735.133 mac os x #0-0]     at async Context.executeAsync (/Users/marianzeis/DEV/ui5-cc-excelUpload/node_modules/.pnpm/@wdio+utils@7.0.0/node_modules/@wdio/utils/build/shim.js:137:16)
[chrome 114.0.5735.133 mac os x #0-0]     at async Context.exports.testFrameworkFnWrapper (/Users/marianzeis/DEV/ui5-cc-excelUpload/node_modules/.pnpm/@wdio+utils@7.0.0/node_modules/@wdio/utils/build/test-framework/testFnWrapper.js:51:18)
[chrome 114.0.5735.133 mac os x #0-0]
[chrome 114.0.5735.133 mac os x #0-0] 2) Upload File List Report Check only strict available
[chrome 114.0.5735.133 mac os x #0-0] grid.getContent is not a function
[chrome 114.0.5735.133 mac os x #0-0] TypeError: grid.getContent is not a function
[chrome 114.0.5735.133 mac os x #0-0]     at Context.<anonymous> (/Users/marianzeis/DEV/ui5-cc-excelUpload/examples/test/specs/all/SetAvailableOptionsListReport.test.js:94:30)
[chrome 114.0.5735.133 mac os x #0-0]     at processTicksAndRejections (node:internal/process/task_queues:95:5)
[chrome 114.0.5735.133 mac os x #0-0]     at async Context.executeAsync (/Users/marianzeis/DEV/ui5-cc-excelUpload/node_modules/.pnpm/@wdio+utils@7.0.0/node_modules/@wdio/utils/build/shim.js:137:16)
[chrome 114.0.5735.133 mac os x #0-0]     at async Context.exports.testFrameworkFnWrapper (/Users/marianzeis/DEV/ui5-cc-excelUpload/node_modules/.pnpm/@wdio+utils@7.0.0/node_modules/@wdio/utils/build/test-framework/testFnWrapper.js:51:18)


Spec Files:      0 passed, 1 failed, 1 total (100% completed) in 00:00:07 

Waiting for the debugger to disconnect...

Screenshots
if applicable, add screenshots to help explain your problem.

Runtime Env (please complete the following information):

  • wdi5/wdio-ui5-service-version: 1.5.0
  • UI5 version: 1.108.14
  • wdio-version (output of wdio --version): v7
  • node-version (output of node --version): 18.14.0
  • OS: macOS
  • Browser + Version Chrome 1.114

Additional context

It works with version 1.84 and up see this workflow run:
https://github.com/marianfoo/ui5-cc-excelUpload/actions/runs/5335263656

Current workaround with regex 😣

const overflowToolbar = await browser.asControl({
			selector: {
				controlType: "sap.m.OverflowToolbar",
				id: new RegExp('^__toolbar.*', 'gm')

			}
		});

I can´t use a fixed id because they are different with every ui5 version 🫠

@Siolto
Copy link
Collaborator

Siolto commented Jun 22, 2023

Hi @marianfoo the declarative ancestor matcher is only available since 1.72 😞. Let me check if I can find a workaround

@Siolto
Copy link
Collaborator

Siolto commented Jun 22, 2023

@marianfoo I had a look again at our coding and forgot that we already tried to fix this by instantiating the relevant matchers programmatically. So it should work with 1.71 and below
We will look into this!

@Siolto Siolto added the bug Something isn't working label Jun 22, 2023
@Siolto Siolto self-assigned this Jun 22, 2023
@Siolto
Copy link
Collaborator

Siolto commented Jun 28, 2023

@vobu @dominikfeininger: we have to discuss about this issue. Some matchers like ancestor or descendent worked differently before 1.72. Maybe we should drop the support for the old versions.

@marianfoo
Copy link
Member Author

I thought about dropping support for the version 1.71 too, but this version is in maintenance till end of 2027 or 2030.
If there are no other options to implement this, what about warnings like i suggestes here in #493 ?

@Siolto
Copy link
Collaborator

Siolto commented Jun 28, 2023

agree. I would extend your #493 with all the problematic matchers and remove the support from the coding or even make a hint there

@vobu
Copy link
Contributor

vobu commented Jul 14, 2023

after an ad-hoc maintainer meeting (😸), we agreed to

  • support the ancestor selector for 1.71 with a dedicated id for the parent
  • log a warning to the console if that selector is used wrongly
  • provide a recipe on how to use the ancestor selector with its' parent id with UI5 1.71
    @Siolto

@github-actions
Copy link

hey 👋 - silence for 30 days 🤐 ... anybody? 😀

@github-actions github-actions bot added the stale label Aug 14, 2023
@github-actions
Copy link

closed 📴 because silencio 🤫 since an additional 14 days after staleness 📠

@Siolto Siolto reopened this Aug 28, 2023
@Siolto
Copy link
Collaborator

Siolto commented Aug 28, 2023

This is still valid

@github-actions github-actions bot removed the stale label Aug 29, 2023
@github-actions
Copy link

hey 👋 - silence for 30 days 🤐 ... anybody? 😀

@github-actions github-actions bot added the stale label Sep 29, 2023
@github-actions
Copy link

closed 📴 because silencio 🤫 since an additional 14 days after staleness 📠

@marianfoo
Copy link
Member Author

marianfoo commented Apr 19, 2024

I have just stumbled across the problem again :/

But this time i guess bindingPath is not working for 1.71?

const settingsButton = await browser.asControl({
			selector: {
				controlType: "sap.m.Button",
				properties: {
					icon: "sap-icon://action-settings"
				},
				bindingPath: {
					path: "",
					propertyPath: "/showOptions",
					modelName: "info"
				},
				searchOpenDialogs: true
			}
		});

@Siolto Siolto reopened this Apr 19, 2024
@Siolto
Copy link
Collaborator

Siolto commented Apr 19, 2024

Thanks for reminding us! We need to have a look at this...

@Siolto
Copy link
Collaborator

Siolto commented Apr 19, 2024

So for the ancestor/descendant case as already discussed:

When we have a stable id we can do something like this in 1.71:

await browser.asControl({
    selector: {
        controlType: "sap.m.StandardListItem",
        viewName: "my.super.view.Name",
        ancestor: "myStableId"
    }
})

When we do not have a stable Id we have to retrieve the control id first:

const ancestorId = await browser.asControl({
            selector: {
                controlType: "sap.m.List",
                viewName: "my.super.view.Name",
            }
        }).getId()

await browser.asControl({
            selector: {
                controlType: "sap.m.StandardListItem",
                viewName: "my.super.view.Name",
                ancestor: ancestorId,
            }
        });

I have also checked the bindingPath case and for me it looks like that it should behave the same in 1.71. like in the higher versions

@github-actions github-actions bot removed the stale label Apr 20, 2024
Copy link

hey 👋 - silence for 30 days 🤐 ... anybody? 😀

@github-actions github-actions bot added the stale label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants