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

combobox special case #191

Merged
merged 7 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client-side-js/_getAggregation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ async function clientSide_getAggregation(webElement, aggregationName) {
if (cAggregation && !Array.isArray(cAggregation)) {
cAggregation = [cAggregation]
}
let result = window.wdi5.createControlIdMap(cAggregation)
// read classname eg. sap.m.ComboBox
controlType = oControl.getMetadata()._sClassName
let result = window.wdi5.createControlIdMap(cAggregation, controlType)
done(["success", result])
} catch (e) {
done(["error", e.toString()])
Expand Down
6 changes: 5 additions & 1 deletion client-side-js/executeControlMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ async function clientSide_executeControlMethod(webElement, methodName, args) {
// 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)

// read classname eg. sap.m.ComboBox
controlType = oControl.getMetadata()._sClassName

result = window.wdi5.createControlIdMap(result, controlType)
done(["success", result, "aggregation"])
} else {
// ui5 api <control>.focus() doesn't have return value
Expand Down
14 changes: 9 additions & 5 deletions client-side-js/injectUI5.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,19 @@ async function clientSide_injectUI5(config, waitForUI5Timeout) {
* @param {[sap.ui.core.Control]} aControls
* @return {Array} Object
*/
window.wdi5.createControlIdMap = (aControls) => {
window.wdi5.createControlIdMap = (aControls, controlType = "") => {
// the array of UI5 controls need to be mapped (remove circular reference)

return aControls.map((element) => {
// just use the absolute ID of the control
let item = {
id: element.getId()
if (controlType === "sap.m.ComboBox" && element.data("InputWithSuggestionsListItem")) {
return {
id: element.data("InputWithSuggestionsListItem").getId()
dominikfeininger marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
return {
id: element.getId()
}
}
return item
})
}

Expand Down
9 changes: 9 additions & 0 deletions examples/ui5-js-app/webapp/controller/Main.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ sap.ui.define(

let testModel = new JSONModel(jData)
this.getView().setModel(testModel, "testModel")

this.initCombobox()
},

initCombobox: function () {
// set explored app's demo model on this sample
var oModel = new JSONModel()
oModel.loadData("model/countries.json")
this.getView().setModel(oModel, "Countries")
},

navFwd() {
Expand Down
36 changes: 36 additions & 0 deletions examples/ui5-js-app/webapp/model/countries.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"CountriesCollection": [
{
"key": "DZ",
"text": "Algeria"
},
{
"key": "AR",
"text": "Argentina"
},
{
"key": "AU",
"text": "Australia"
},
{
"key": "AT",
"text": "Austria"
},
{
"key": "BH",
"text": "Bahrain"
},
{
"key": "BE",
"text": "Belgium"
},
{
"key": "BA",
"text": "Bosnia and Herzegovina"
},
{
"key": "BR",
"text": "Brazil"
}
]
}
43 changes: 43 additions & 0 deletions examples/ui5-js-app/webapp/test/e2e/combobox.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const Main = require("./pageObjects/Main")

const oComboboxSelector = {
forceSelect: true,
selector: {
interaction: "root",
id: "combobox",
viewName: "test.Sample.view.Main"
}
}

// #121
describe("ui5 sap.m.Combobox", () => {
before(async () => {
await Main.open()
})

it("get combobox items aggregation as WebdriverIO representations", async () => {
const combobox = await browser.asControl(oComboboxSelector)

// no need to open the combobox
const items = await combobox.getItems(true)
expect(items.length).toEqual(8)
})

it("get combobox single item aggregation as ui5 items", async () => {
const combobox = await browser.asControl(oComboboxSelector)
// another issue with the combobox. If the Box was not opend prevoiusly the items are not rendered -> unretrieveable with ui5
await combobox.open()

const items = await combobox.getItems(4)
expect(await items.getTitle()).toEqual("Bahrain")
})

it("get combobox items aggregation as ui5 items", async () => {
const combobox = await browser.asControl(oComboboxSelector)
// another issue with the combobox. If the Box was not opend prevoiusly the items are not rendered -> unretrieveable with ui5
await combobox.open()

const items = await combobox.getItems()
expect(await items[4].getTitle()).toEqual("Bahrain")
})
})
9 changes: 9 additions & 0 deletions examples/ui5-js-app/webapp/view/Main.view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@
<Button text="open Dialog"
press="openDialog"
id="openDialogButton" />
<Label text="Country Combobox"/>
<ComboBox
id="combobox"
items="{
path: 'Countries>/CountriesCollection',
sorter: { path: 'text' }
}">
<core:Item key="{Countries>key}" text="{Countries>text}" />
</ComboBox>
<!-- TODO -->
<!-- <SearchField id="idSearchfield" value="{testModel>/searchValue}"/> -->
</VBox>
Expand Down