wdi5
wdi5 copied to clipboard
0.9.10: Not possible to catch browser.asControl() exception
Hi,
as it is not possible with WDI5's browser.asControl() to check if a element does not exist on the screen, we up to now catched the thrown exception (see issue https://github.com/ui5-community/wdi5/issues/139).
Since version 0.9.10 this does not work anymore, as the catch block is not reached anymore:
async expectNotToExist(oControlSelector) {
try {
var oControl = await browser.asControl(oControlSelector);
} catch (e) {
await expect(e.message).toEqual(expect.stringContaining("[wdi5]call of _getControl() failed because of: Error: No DOM element found using the control selector"));
return;
}
//This expect needs to be outside of try-catch, to avoid that a exception of this .not.toExist() call is feteched as well.
await expect(await oControl.getWebElement()).not.toExist();
}
The yellow part in the attached screenshot was not print out in earlier WDI5 versions (with log level error):
-
wdi5/wdio-ui5-service
-version: 0.9.10 -
UI5
version: 1.104.2 -
wdio
-version (output ofwdio --version
): 7.19.7 -
node
-version (output ofnode --version
): v16.16.0 - OS: Windows 10
- Browser + Version: Chrome 103.0.5060.134 (Official Build) (64-bit)
thanks for providing the code that we can use as a minimal reproducible example 👍 we‘ll look into this and report back and meanwhile just fyi: there was a major improvement in detailed error messages coming in with https://github.com/ui5-community/wdi5/commit/f7b318263fe9eebc87ede950feeece51b865dec2 hopefully we didn‘t break exceptions with that 😐👀
Hi @sebage,
bug confirmed! Thanks for reporting that issue.
The error with the message control could not be found
shouldn't be thrown like that. There should be an additional entry in the log like Can not call "getWebElement()", because control could not be found
.
btw: to check that an element is not visible on the screen/does not exist you could als try to use a native wdi5 function called isInitialized()
. This will be false when no DOM element was found. Your check could look something like that:
const oControl = await browser.asControl(controlSelector)
expect(await oControl.isInitialized()).toBeFalsy()