Closed marco-paciucci closed 2 years ago
have you specified the "ui5" service in wdio.conf.js
?
https://ui5-community.github.io/wdi5/#/installation?id=c-manual-installation
also, you'll need to await
the button click in your test "Step2: should display the todo list": await button.click()
Hello,
nope await button.click()
is not a valid SAP UI5 statement and click
method doesn't exist.
Anyway there's something that doesn't tally up.
const selector = {
selector: {
controlType: "sap.m.List",
viewName: "sap.ui.demo.todo.view.App"
}
}
const oControl = await browser.asControl(selector);
const oModel = await oControl.getModel();
wdi5.getLogger("MYLOG....Data of the model is ").log(oModel);
const aTodos = await oModel.getProperty("/todos");
const count = await aTodos.filter( el=>{if (el.completed) return 1; else return 0;}).length;
wdi5.getLogger("MYLOG....The number of completed items is ").log(count);
The javascript code is perfectly fine and it works okay on the server
However npm run wdi5 returns an error:
oModel.getProperty is not a function
and I cannot seem to figure out how to get it sorted.
nope
await button.click()
is not a valid SAP UI5 statement andclick
method doesn't exist
that's correct, should have been await button.press()
const oModel = await oControl.getModel() const aTodos = await oModel.getProperty("/todos")
getModel()
returns a complex object - so far, atomic values and UI5 controls are working in wdi5
, but not complex objects. We're working on that in #252.
Glancing at your source and guessing for the rest: for your use case, getting all list items, then iterating them for the property checked
(or similar), might be an alternative solution, à la (attention, untested code ahead)
const checkedItems = await browser.asControl(listSelector).getItems()
const checked = 0
for (const item of checkedItems) {
if (await item.getChecked()) { checked++ }
}
expect(checked).toBe(2)
anyway, this issue now doesn't seem to be related to your original issue with cannot read properties...
, or is it?
The original issue is gone and I will close this. It was due to the version of npm which was wrong and the installation wasn't completed successfully. I will then raise a separate issue for this code. Thank you
Hello, I have this piece of code in my test.js:
which returns:
[chrome 104.0.5112.81 windows #0-0] javascript error: Cannot read properties of undefined (reading 'waitForUI5Options') JavaScript stack: TypeError: Cannot read properties of undefined (reading 'waitForUI5Options') at eval (eval at executeAsyncScript (:552:26),:4:65)
at eval (eval at executeAsyncScript (:552:26), :33:8)
at eval (eval at executeAsyncScript (:552:26), :33:33)
at executeAsyncScript (:552:47)
at apply.selector.bindingPath.path (:567:29)
at callFunction (:446:22)
at :460:23
at :461:3
(Session info: chrome=104.0.5112.81)
The file wdio.conf.js contains this configuration:
And package.json
Why am I getting this issue?