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

Failed to find control with error "Error: waitAsync is already running and cannot be called again at this moment" #108

Closed cwang1221 closed 2 years ago

cwang1221 commented 2 years ago

Hi Experts,

There's a strange error in my test. My test is very simple, after opening the page, there are two assertions: asserting control A is visible and asserting control B is visible.

If I only write any one of the assertions, the test will pass. But if both assertion exists (no matter what the sequence is), the first one will be success but the second will fail with error: "Error: waitAsync is already running and cannot be called again at this moment". Any idea on this? Thank you!

UI5 version: 1.97.1

Thank you and best regards, Cong

cwang1221 commented 2 years ago

Some more information: image

my .conf.js file:

exports.config = {
    runner: "local",
    specs: [
        "./tests/wdi5/specs/dpp/*.spec.js"
    ],
    exclude: [],
    maxInstances: 1,
    capabilities: [{
        maxInstances: 1,
        browserName: "chrome",
        acceptInsecureCerts: true
    }],
    wdi5: {
        screenshotsDisabled: true,
        logLevel: "error",
        platform: "browser",
        url: "",
        deviceType: "web",
        waitForUI5Timeout: 120000,
        skipInjectUI5OnStart: true
    },
    logLevel: "error",
    logLevels: {
        webdriver: "error",
    },
    bail: 0,
    baseUrl: process.env.CUSTOM_URL,
    waitforTimeout: 120000,
    connectionRetryTimeout: 120000,
    connectionRetryCount: 3,
    services: ["chromedriver", "ui5"],
    framework: "mocha",
    reporters: ["spec"],
    mochaOpts: {
        ui: "bdd",
        timeout: 120000
    }
};

My test:

const Ui5Service = require("wdio-ui5-service").default;
const ui5Service = new Ui5Service();

describe("I check DPP.", function () {
    it("I check customers in DPP.", () => {
        browser.goTo("<my ui5 page>");
        ui5Service.injectUI5();

        expect(browser.asControl({
            selector: {
                id: "idSearchMaster",
                viewName: "deleteDataSubjects.view.Master"
            }
        }).getVisible()).toBeTruthy();
        expect(browser.asControl({
            selector: {
                id: "idMasterApplGroupFilter",
                viewName: "deleteDataSubjects.view.Master"
            }
        }).getVisible()).toBeTruthy();
    });
});
dominikfeininger commented 2 years ago

Hi @cwang1221 ,

I wasn't able to reproduce this in our rather small test environment. (https://github.com/js-soft/wdi5/blob/develop/wdio-ui5-service/test/ui5-late.test.js)

I placed this snippet

`it.only('I check the header visibility in Master Page', () => { // open ui5 page browser.url('https://openui5.netweaver.ondemand.com/index.html'); // do the late injection ui5Service.injectUI5();

    expect(
        browser
            .asControl({
                selector: {
                    id: 'sdk---app--controlsMasterTab',
                    viewName: 'sap.ui.documentation.sdk.view.App'
                }
            })
            .getVisible()
    ).toBeTruthy();

    expect(
        browser
            .asControl({
                selector: {
                    id: 'sdk---app--apiMasterTab',
                    viewName: 'sap.ui.documentation.sdk.view.App'
                }
            })
            .getVisible()
    ).toBeTruthy();
});`

in ui5-late.test.js and ran npm run test:ui5_late .

image

Your conf file looks fine, I also played around with different settings -> same result.

cwang1221 commented 2 years ago

Hi @dominikfeininger, thank you for your quick reply! I think so because I could successfully test other apps with the same UI5 version. It seems to be some problems with the app (not sure). I just want to know if you have any hint on the error "Error: waitAsync is already running and cannot be called again at this moment"? If you know any possible reason/solution of it? Thank you!

dominikfeininger commented 2 years ago

I never experienced this behavior. Maybe @vobu https://github.com/SAP/ui5-uiveri5/issues/268 can give a hint?

cwang1221 commented 2 years ago

Hi @dominikfeininger, I think I find the reason, the page I was testing is trying to get <...>/resources/sap/dfa/help/utils/adapters/fiori/Component-preload.js. But the request keep pending there, which cause the autoWait to keep waiting. After I blocked the request, the test passed.

Thank you and will close this issue.

BeastiW commented 2 years ago

Hi @dominikfeininger, try to get an aggregation (e.g. getItems()) as the 2nd call - then it will fail each time - at least in my test project, see attached zip file. Do you have a solution for this? I assume this is not really solved and we should maybe reopen this issue.

Cheers Bas sample_wdi5.zip .

vobu commented 2 years ago

@BeastiW thanks for sending over a sample, that makes debugging and support easier 👍 hate to break it to you, but: your tests are fine coding-wise 😸 they fail though:

"spec" Reporter:
------------------------------------------------------------------
[chrome 97.0.4692.99 mac os x #0-0] Running: chrome (v97.0.4692.99) on mac os x
[chrome 97.0.4692.99 mac os x #0-0] Session ID: 97970786dc53cb42ef2688c82c7328c6
[chrome 97.0.4692.99 mac os x #0-0]
[chrome 97.0.4692.99 mac os x #0-0] » /features/sample.feature
[chrome 97.0.4692.99 mac os x #0-0] Start der App und Auswahl des Select "Features"
[chrome 97.0.4692.99 mac os x #0-0] Dies ist der grundlegende Workflow für die App
[chrome 97.0.4692.99 mac os x #0-0]
[chrome 97.0.4692.99 mac os x #0-0] Ich starte die App und wähle einen Eintrag aus, der dann angezeigt wird.
[chrome 97.0.4692.99 mac os x #0-0]    ✓ Gegeben sei Ich starte die App
[chrome 97.0.4692.99 mac os x #0-0]    ✓ Wenn ich auf den Select klicke
[chrome 97.0.4692.99 mac os x #0-0]    ✓ Und ich den Eintrag "hello" auswähle
[chrome 97.0.4692.99 mac os x #0-0]    ✓ Dann sehe ich "hello" im Eingabefeld
[chrome 97.0.4692.99 mac os x #0-0]    ✓ Wenn ich auf den Select klicke
[chrome 97.0.4692.99 mac os x #0-0]    ✓ Und ich den Eintrag "world" auswähle
[chrome 97.0.4692.99 mac os x #0-0]    ✖ Dann sehe ich "world" im Eingabefeld
[chrome 97.0.4692.99 mac os x #0-0]
[chrome 97.0.4692.99 mac os x #0-0] 6 passing (46.3s)
[chrome 97.0.4692.99 mac os x #0-0] 1 failing
[chrome 97.0.4692.99 mac os x #0-0]
[chrome 97.0.4692.99 mac os x #0-0] 1) Ich starte die App und wähle einen Eintrag aus, der dann angezeigt wird. Dann sehe ich "world" im Eingabefeld
[chrome 97.0.4692.99 mac os x #0-0] Error: expect(received).toBe(expected) // Object.is equality
[chrome 97.0.4692.99 mac os x #0-0] Error: expect(received).toBe(expected) // Object.is equality
[chrome 97.0.4692.99 mac os x #0-0]
[chrome 97.0.4692.99 mac os x #0-0] Expected: "world"
[chrome 97.0.4692.99 mac os x #0-0] Received: "hello"
[chrome 97.0.4692.99 mac os x #0-0]     at World.<anonymous> (/Users/vbuzek/Downloads/sample_wdi5/webapp/test/steps/steps.js:40:5)
[chrome 97.0.4692.99 mac os x #0-0]     at processTicksAndRejections (node:internal/process/task_queues:96:5)

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

but i had to make changes in the setup to get things running:

here are the changed files, w/ modified extensions due to gh upload restrictions:

if your issues persist, please open up a new issue in here - the report template will guide through all the information that we need to make debugging and support easier. thanks!

BeastiW commented 2 years ago

@vobu thanks for your support and the changed files.

... for future references: the line in wdio.conf.js was the problem (probably because I didn't include it in my package.json): automationProtocol: "devtools"