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

Problem getting selected keys from MultiComboBox-control #160

Closed
ph-alsvik opened this issue Mar 2, 2022 · 4 comments
Closed

Problem getting selected keys from MultiComboBox-control #160

ph-alsvik opened this issue Mar 2, 2022 · 4 comments

Comments

@ph-alsvik
Copy link
Contributor

Hello folks!

So I have an app with a MultiComboBox control with string-valued keys. I've written a simple test in wdi5 which gets this control and checks if a certain key is preset. The test looks like this:

it("validates that 'temperature' sensor is pre-selected", async () => {
        const oSelector = {
            forceSelect: true,
            timeout: 15000,
            selector: {
                interaction: "root",
                controlType: "sap.m.MultiComboBox",
                id: "sensor-select",
                viewName: "app.view.main"
            }
        };
        const control = await browser.asControl(oSelector);
        const selectedKeys = await control.getSelectedKeys();
        expect(selectedKeys[0]).toEqual("temperature");
});

I get the control without issue, but when calling the getSelectedKeys-method on it, it fails with a timeout-error.

Inspecting the console in the browser reveals that there is a type error in the code running in the client:

Uncaught (in promise) TypeError: element.getId is not a function
    at eval (eval at executeAsyncScript (index.html:552:26), <anonymous>:228:45)
    at Array.map (<anonymous>)
    at Object.window.wdi5.createControlIdMap (eval at executeAsyncScript (index.html:552:26), <anonymous>:225:42)
    at eval (eval at executeAsyncScript (index.html:552:26), <anonymous>:22:42)
    at v (_promiseWaiter.js:6:2327)

Have I written the test wrong or is this a bug?

If something is unclear with this issue, just let me know.

Thank you!

@vobu
Copy link
Contributor

vobu commented Mar 3, 2022

hi! all looking good on your code (except the timeout selector option that doesn‘t exist (https://js-soft.github.io/wdi5/#/configuration?id=wdi5) 😝)
we still have an issue with ComboBox → see #121
so it‘s on our todo, but not yet done
ok for you to track this in #121 and closing this?

@ph-alsvik
Copy link
Contributor Author

Thanks for your reply! Yes, I'll close this issue. Just want to add one final thing:

I did a little investigation myself. I think the issue is related to this part in executeControlMethod.js:

if (Array.isArray(result)) {
    // expect the method call delivers non-primitive results (like getId())
    // but delivers a complex/structured type
    // -> currenlty, only getAggregation(...) is supported
    result = window.wdi5.createControlIdMap(result)
    done(["success", result, "aggregation"])
}

It seems that when the returned value of one of the get$Shorthand-methods is an array, wdi5 assumes its an array of objects, but in case of getSelectedKeys its an array of strings.

Perhaps you already know, but sharing my knowledge just in case 😃

@vobu
Copy link
Contributor

vobu commented Mar 3, 2022

Thanks for your reply! Yes, I'll close this issue. Just want to add one final thing:

I did a little investigation myself. I think the issue is related to this part in executeControlMethod.js:

if (Array.isArray(result)) {
    // expect the method call delivers non-primitive results (like getId())
    // but delivers a complex/structured type
    // -> currenlty, only getAggregation(...) is supported
    result = window.wdi5.createControlIdMap(result)
    done(["success", result, "aggregation"])
}

It seems that when the returned value of one of the get$Shorthand-methods is an array, wdi5 assumes its an array of objects, but in case of getSelectedKeys its an array of strings.

Perhaps you already know, but sharing my knowledge just in case 😃

excellent, thanks for the hint!
now that you're already that close to the root cause....how about giving a fix and a Pull Request a shot?!? 🚀

i'm just writing the dev time setup/onboarding doc (see #163), but here's the gist:

# you need npm 7+ → we're using npm's workspaces feature
$> npm --version
# will also install all deps in workspaces + setup pre-commit hooks
$> npm i 
# build entire proj once
$> npm run build
# turn on build watcher
$> npm run build:watch

Then to work on a test:
...in terminal 1:

# start the sample js app
$> npm run _startApp:js

...in terminal 2:

# run a single test with wdi5/wdio
### runs the "test:websever" script from /examples/ui5-js-app/package.json
### in workspace "examples/ui5-js-app"
### but only any test file in /examples/ui5-js-app/webapp/test/e2e/**/* that
### matches "basic" in the filename
### and run in watch mode (browser stays open, test reruns when file changes)
### for true TDD 
$> npm run test:webserver -w examples/ui5-js-app -- --spec basic --watch

@ph-alsvik
Copy link
Contributor Author

Sure! I'll try to fix it 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants