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

Can't retrieve Control by Id using selector #343

Closed fIannazzo closed 2 years ago

fIannazzo commented 2 years ago

Describe the bug I have added the wdi5 framework to the openui5 sample app to play around with the framework. I'm trying to select the List Item by using an selector on id field

const selector = { forceSelect: true, selector: { id: "container-todo---app--todoList", }, };

const oList = await browser.asControl(selector); console.log("List ID " + (await oList.getId()));

To Reproduce Steps to reproduce the behaviour:

Clone https://github.com/fIannazzo/openui5-sample-app and run

node_modules/.bin/wdio run wdio.conf.js in Debug console.

Expected behavior I would expect oList.getId() to be something like "container-todo---app--todoList" but ID is "container-todo---app--todoList-trigger". Seems the selector for id does not work correctly.

Logs/Console Output

Screenshot 2022-09-14 at 10 28 57

Screenshots

Screenshot 2022-09-14 at 10 16 37

Expected the green as id, but getting the red one with trigger at the end.

Runtime Env (please complete the following information):

Additional context Add any other context about the problem here, e.g. any options the target browser is started with like --headless or if the tests run in a CI environment

vobu commented 2 years ago

you're most likely missing interaction: "root" in the selector. it's a UI5 core/OPA5 thingie for retrieving controls that we documented at https://ui5-community.github.io/wdi5/#/recipes?id=using-interaction-on-a-selector

Siolto commented 2 years ago

As @vobu already written: The interaction: "root" selector is missing. I also had a look at your test and saw that you use the lateInjection of wdi5 even though you are directly starting the tests in an UI5 Application. I updated your script a little bit and this works fine:

describe("My Login application", () => {
    it("before", async () => {
        const selector = {
            forceSelect: true,
            selector: {
                id: "container-todo---app--todoList",
                interaction: "root"
            },
        };
        const oList = await browser.asControl(selector);
        expect((await oList.getItems()).length).toEqual(2)
    });
});